Determining response codes from void functions OOP

by Mike   Last Updated April 16, 2019 08:05 AM

I am trying to create a Put endpoint using rest. Let's say that under the link


I am trying to add a new address (if that id doesn't exist) or I'm trying to update it if it does already exist.

My application has several layers Controllers, Services, Models and Repositories. Given the fact that the business layer decides if an update or an add is required (this logic takes place in the service layer and below), how would the controllers be able to find out if an update or an add happened and return the correct status codes (201 for resource created, 204 if just an update has occured)?

My only ideas are to return some sort of result object, but that doesn't feel particularly correct. For the cases where the service methods are not void, they usually return DTOs.

Related Questions

Updated March 07, 2018 03:05 AM

Updated November 09, 2017 20:05 PM

Updated March 06, 2018 02:05 AM

Updated June 24, 2017 02:05 AM