Hi Guys,

I have a decision to make to solve a problem, I’m describing the problem below.

Application Overview

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.

enter image description here

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.

enter image description here

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)

Possible Issues:
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.

Possible Solutions

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.

enter image description here

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.

for more details on QBWI.

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.

2 Answers 2


B definitely sounds like the only sane choice.

A means depending on implementation details of the REST API. It makes the "transaction" very fragile, breaks encapsulation, and other bad things.

C I'm not entirely sure what you're saying you'll do with a QBWI (beyond the email to admin part), but it doesn't sound like an actual solution to the problem. Something as simple and fundamental as transaction semantics definitely needs to be handled by the software, not by human admins.

In the real world, the "disjoint team" may fail to deliver a real solution. This would be when you talk to business managers and explain to them that you can do a hacky workaround (A or C) in the short term but you really need the other team to give you a proper API someday. They're the ones in a position to decide whether it's better for the company to do the workaround now or have you do something else for the time being.

  • hmm,I was expecting this response,Alright but due to the time constraints I would perform the hacky workaround (C),do you have any suggestions for performing background tasks with asp.net mvc ? Jan 26, 2015 at 8:34
  • That goes beyond my personal expertise. You may want to ask that as a separate question (presumably on SO).
    – Ixrec
    Jan 26, 2015 at 9:30

there is problem in ur requirement gathering 1st u said "...(its the independent record) and then I can proceed with the person_id to create Phone,Email and Address"

then u said : If the person creation succeeds but one or more preceding record creation fails then actually Employee creation fails"

means it is not independent.

lets assume its independent then it means user can add orr update its address resource, phone resource etc after words.

solution like u can redesign this screen in way that first u create user with Person Resource and then get his other informations afterwards.

and if its dependent then u cannot disjoint the resource like that, in API u have give complete information to perform task. User creation is a task and its complete information is all together.

  • I think you are mixing things here,In-order to create employee I must create (Person first then create other records which are dependent on the Person),you need to look employee as a Domain object (required by the business) and API Endpoints namely Person,Email,Address and Phone as objects (object model and db design) exposed by the API. Jan 26, 2015 at 9:25
  • "there is problem in ur requirement gathering",we are not performing the requirement gathering,we are just developing the WebApp by using the Rest API,so we are restricted with the provided set of Resource URI/EndPoints. Jan 26, 2015 at 9:35
  • "(object model and db design) exposed by the API" is not a Rest API
    – mastermind
    Jan 26, 2015 at 10:16
  • "not performing the requirement gathering" then its mean APIs are not according to the requriement
    – mastermind
    Jan 26, 2015 at 10:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.