I have a decision to make to solve a problem, I’m describing the problem below.
I have an ASP.NET MVC 4 webApp which uses Rest Api for almost all the tasks, from Login to CRUD on the records.
The rest api is being developed by a separate disjoint team and the webApp is being developed my me.
There is a particular scenario which leads me to think that something is not right may be the Api is having an issue or I’m not developing the WebApp the right way.
I made a screen for Employee creation, it collects several information related to an employee, on submit to the server I collect these information serialize them into json and send them to Resource URI using the POST method.
The problem is in order to create a single employee I would need to hit four Resource URI one by one,the Person needs to be created first (its the independent record) and then I can proceed with the person_id to create Phone,Email and Address.
Person > (Phone | Email | Address)
Now If the Person creation fails I would show user that the operation failed and he/she could try again. If the person creation succeeds but one or more preceding record creation fails then actually Employee creation fails,it's kind of a transaction all record should be created to successfully create employee. Also a useless person will be hanging around of no worth and then the Application user might try to create the employee again and this problem may happen again.
A) Solution at my End: Make a windows service running with a scheduler,which checks a DB if failed requests are there,and if it finds any it performs the api request to complete the tasks.
B) API Level Solution: Make an Employee Resource URI which is able to receive the json of all the distinct json objects in a single go and respond with result. Of course these separate json object may correspond to separate DB tables and the API developer will handle them through transaction.
C) Use QueueBackgroundWorkItem use the QBWI to quickly make several async request for the failed resources and return with failed and success message also log and email the admin,no need to manage a separate Windows Service and a DB.
Remarks: I will go for the solution B ,its seems like the best option but due to time constraint I might need to apply the solution (C)
Guys I need you to critically examine the scenario and the solution sections and provide me analysis and the best possible solution.