Esempio n. 1
0
        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));
        }
Esempio n. 2
0
 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));
     }
 }
Esempio n. 3
0
        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));
        }