public async Task <IActionResult> Delete(int id) { var isDeleted = await _service.Delete(id); if (isDeleted) { return(RedirectToAction(nameof(Index))); } ModelState.AddModelError("", "Something went wrong..."); return(RedirectToAction(nameof(Index))); }
// DELETE: api/LeaveTypes/5 public HttpResponseMessage DeleteLeaveType(int id) { try { var message = Request.CreateErrorResponse(HttpStatusCode.NotFound, "404 : Data Not Found"); var result = iLeaveTypesService.Delete(id); if (result) { message = Request.CreateResponse(HttpStatusCode.OK, "200 : OK (Data Deleted)"); } return(message); } catch (Exception e) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "500 : Internal Server Error")); } }