public JsonResult Approve(ApproveRejectLeaveViewModel vm) { ApiResult <ApproveRejectLeaveViewModel> result; var leave = _leaveRepository.GetBy(r => r.Id == vm.Id, "RequestedForUser.User.Person"); var employee = _employeeRepository.GetBy(r => r.UserId == WebUser.Id); var status = _leaveService.Approve(vm.Id, employee.Id, vm.ApproverComments, false); if (status) { #if !DEBUG _emailComposerService.LeaveApprovalEmail(vm.Id, false); #endif result = new ApiResult <ApproveRejectLeaveViewModel> { Status = true, Message = "Leave Approved", Result = vm }; } else { result = new ApiResult <ApproveRejectLeaveViewModel> { Status = false, Message = "Not Enough Balance to Approve the Leave", Result = null }; } return(Json(result)); }
public IActionResult Approve(LeaveRequestHistory leave) { try { return(Ok(_leaveService.Approve(leave))); } catch (Exception ex) { message = ex.Message; _log.LogError(message); return(StatusCode(StatusCodes.Status500InternalServerError, message)); } }
public ActionResult Leave() { var pendingLeaves = _leaveService.GetPendingLeaves(); foreach (var pendingLeave in pendingLeaves) { var status = _leaveService.Approve(pendingLeave.Id, 1, "Auto Approved by Grid-Bot", true); if (status) { #if !DEBUG _emailComposerService.LeaveApprovalEmail(pendingLeave.Id, true); #endif } } return(Json(true, JsonRequestBehavior.AllowGet)); }