// DELETE api/values/5 public void Delete(int id) { try { if (!employeeDataAccess.DeleteEmployee(id)) { throw new HttpResponseException(HttpStatusCode.NotFound); } } catch (Exception ex) { var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(string.Format("Unable to process this request, due to some internal error")), StatusCode = HttpStatusCode.InternalServerError, ReasonPhrase = "Unable to process this request, due to some internal error" }; throw new HttpResponseException(resp); } }
public async Task <IActionResult> DeletePost([FromBody] Employee model) { int result = 0; if (model.EmpId == 0) { return(BadRequest()); } try { result = await employeeManagement.DeleteEmployee(model.EmpId); if (result == 0) { return(NotFound()); } return(Ok()); } catch (Exception) { return(BadRequest()); } }