public async Task <IActionResult> Post([FromBody] RewardRegion region) { if (region == null) { // return HTTP 400 badrequest as something is wrong return(BadRequest("Region information formatted incorrectly.")); } var rgn = new RewardRegion() { Region_name = region.Region_name, Projects = region.Projects }; // Save the new user to the DB var result = await _rewardRepository.CreateRegion(rgn); if (result == 1) { // return HTTP 201 Created with country object in body of return and a 'location' header with URL of newly created object return(CreatedAtAction("Get", new { region_name = region.Region_name }, rgn)); } else if (result == -10) { // return HTTP 409 Conflict as user already exists in DB return(Conflict("Region with name '" + region.Region_name + "' already exists. Cannot create a duplicate.")); } else { // return HTTP 400 badrequest as something is wrong return(BadRequest("An internal error occurred. Please contact the system administrator.")); } }