Exemple #1
0
        public JsonResult Save(EmployeeLeaveRequestModel employeeLeaveRequest, bool isInsert)
        {
            var leaveBalanceInformation = _employeeLeaveInformationService.GetEmployeeLeaveBalanceInformation(employeeLeaveRequest.EmployeeId);

            if (leaveBalanceInformation.Any())
            {
                var requestedLeaveTypeBalance = leaveBalanceInformation.FirstOrDefault(s => s.LeaveTypeId == employeeLeaveRequest.LeaveTypeId);
                if (requestedLeaveTypeBalance != null && requestedLeaveTypeBalance.RemainingDays > 0)
                {
                    employeeLeaveRequest.RequestDate = DateTime.Now;
                    if (isInsert)
                    {
                        employeeLeaveRequest.ApprovalStatusId = 1;

                        employeeLeaveRequest.SetCreateProperties(LoginInformation.UserInformation.Id);
                        employeeLeaveRequest.Id = _employeeLeaveRequestService.Insert(employeeLeaveRequest);
                    }
                    else
                    {
                        employeeLeaveRequest.SetUpdateProperties(LoginInformation.UserInformation.Id);
                        _employeeLeaveRequestService.Update(employeeLeaveRequest);
                    }
                    return(Json(new { Success = true, Data = employeeLeaveRequest }));
                }
            }
            return(Json(new { Success = false, Message = "You do not have sufficient leave balance of requested type." }));
        }
Exemple #2
0
        public ActionResult LeaveBalance([DataSourceRequest] DataSourceRequest request, long employeeId)
        {
            var leaveBalanceInformation = _employeeLeaveInformationService.GetEmployeeLeaveBalanceInformation(employeeId);

            return(Json(leaveBalanceInformation.ToDataSourceResult(request)));
        }