public ActionResult DeleteLeaveType(int id) { try { _leaveTypeService.DeleteLeaveType(id); ViewBag.Success = "The leave type has been deleted."; return(Redirect("/leavetype")); } catch (Exception Ex) { var leaveTypeList = _leaveTypeService.GetLeaveTypes().OrderByDescending(x => x.LeaveTypeId); ModelState.AddModelError("ForeignKeyError", "This leave cannot be deleted as it has already been associated."); return(View("LeaveType", leaveTypeList)); } }
//[Authorize(Policy = "DeleteRolePolicy")] public async Task <IActionResult> Delete(string Id, int Ids = 0) { int lveTypeDecryptedId = Convert.ToInt32(protector.Unprotect(Id)); try { await leaveTypeService.DeleteLeaveType(lveTypeDecryptedId); return(RedirectToAction("Index")); } catch (Exception) { ViewBag.ErrorMessage = $"The Department cannot be deleted becouse of reference constraint of his/her Id in another database"; return(View("CustomError")); } }
public async Task <IActionResult> DeleteLeaveType(int LeaveTypeId) { try { var response = await _service.DeleteLeaveType(LeaveTypeId); if (response != null) { return(Ok(response)); } return(StatusCode(StatusCodes.Status204NoContent)); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> DeleteLeaveType(int id) { try { if (id != 0) { var leaveType = await leaveTypeService.DeleteLeaveType(id); return(Ok(leaveType)); } return(BadRequest()); } catch (Exception) { return(BadRequest()); } }
public bool DeleteLeaveType(int id) { return(_LeaveTypeService.DeleteLeaveType(id)); }