public async Task <ActionResult <object> > DeleteAsync(int id) { try { int retVal = await _userServiceAsync.Remove(id); if (retVal >= 0) { var toSerialize = new MessageHelpers <UserViewModel>() { Status = 200, Data = null }; return(JsonConvert.SerializeObject(toSerialize)); } else { var toSerialize = new MessageHelpers <UserViewModel>() { Status = 404, Data = null }; return(JsonConvert.SerializeObject(toSerialize)); } } catch { var toSerialize = new MessageHelpers <UserViewModel>() { Status = 502, Data = null }; return(JsonConvert.SerializeObject(toSerialize)); } }
public async Task <IActionResult> Delete(int id) { if (await _userServiceAsync.Remove(id)) { return(NoContent()); //204 } else { return(NotFound()); //404 } }
public async Task <IActionResult> Delete(int id) { int retVal = await _userServiceAsync.Remove(id); if (retVal == 0) { return(NotFound()); //Not Found 404 } else if (retVal == -1) { return(StatusCode(412, "DbUpdateConcurrencyException")); //Precondition Failed - concurrency } else { return(NoContent()); //No Content 204 } }