I'm using Asp.net Core 2.0 Web API to create some database entries in SQL Server.I don't want to create duplicate rows and i want to inform the consumer of the API know that it's trying to create duplicate rows. i have two controller actions to create these entries witch the first one Accepts only one instance of the object
to be created and the second one accept a List<object>
all to be created. for the first action method if the row is duplicate i respond with a Http Conflict(409) error and if not i resend the processed object back to the consumer inside an OK Http response.
In the second action method i am getting a list of the objects and maybe some of them are duplicate and some are not. I'm trying to do a best practice by adding the non-duplicate entries and sending back an error for duplicate ones. the problem here is that how should be my response? an OK response or Conflict? further more i want the consumer to know witch objects are created and witch ones not, for the added ones i want to send back the object itself in a list and for the duplicate ones i want to send them back with a duplicate flag!. here it's important for met to get a best practice solution and not just a complex solution.
TL;DR There is an action of post method for a Web API to Create a List of the objects, How the Respond must be when some of the objects are duplicate and others are not in a clear and best practice way.