public JsonResult GetLeaveStatus()
        {
            JsonResult result = null;

            try
            {
                EmployeeLeaveDetails employeeLeaveDetails = new EmployeeLeaveDetails();
                employeeLeaveDetails.AppliedStatusCount = Leaveservice.GetLeaveList <EmployeeLeaveList>(s => s.Status == "Applied" && s.BranchId == USER_OBJECT.BranchId && s.EmployeeId == USER_OBJECT.EmployeeId).Count();
                var GrantedLeavesList = Leaveservice.GetLeaveList <EmployeeLeaveList>
                                            (s => s.EmployeeId == USER_OBJECT.EmployeeId && s.BranchId == USER_OBJECT.BranchId)
                                        .GroupBy(g => g.LeaveTypeId).ToList().Select(s => new
                {
                    count = s.Count(),
                    name  = LookUpCodeService.GetLookUpType(s.Key).LookUpCode
                });
                employeeLeaveDetails.GrantedLeaves = Leaveservice.GetLeaveList <EmployeeLeaveList>(s => s.Status == "Grant" && s.BranchId == USER_OBJECT.BranchId && s.EmployeeId == USER_OBJECT.EmployeeId).Count();
                List <LeaveHeader> LeaveHeaders = GrantLeaveService.GetAll <LeaveHeader>(l => l.BranchID == USER_OBJECT.BranchId).ToList();
                var TotalLeaves = LeaveHeaders.Select(l => l.LeaveDetail.Sum(s => s.TotalLeaves)).Count();
                employeeLeaveDetails.RemaingStatusCount = Math.Abs(employeeLeaveDetails.GrantedLeaves - TotalLeaves);
                result = Json(new { employeeLeaveDetails = employeeLeaveDetails, GrantedLeavesList = GrantedLeavesList }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    return(Json(new { success = false, message = ex.InnerException.Message }, JsonRequestBehavior.DenyGet));
                }
            }
            return(result);
        }
Beispiel #2
0
        public JsonResult GetAppliedLeaveList()
        {
            JsonResult result = null;

            try
            {
                LookUp employeeDepartment = LookUpCodeService.GetLookUp <LookUp>(s => s.LookUpCategory == "EmployeeDesignation" && s.LookUpCode == "Manager").FirstOrDefault();

                EmployeeHeader employeeHeader = EmployeeProfileService.GetEmployeeProfileList <EmployeeHeader>(e => e.Id == USER_OBJECT.EmployeeId && e.EmployeeWorkDetail.FirstOrDefault().DesignationId == employeeDepartment.LookUpID).FirstOrDefault();

                List <EmployeeLeaveList>      employeeLeaveList          = Leaveservice.GetLeaveList <EmployeeLeaveList>(e => e.ManagerId == employeeHeader.Id).OrderBy(o => o.EmployeeId).ToList();
                List <EmployeeLeaveViewModel> employeeLeaveViewModelList = new List <EmployeeLeaveViewModel>();
                foreach (EmployeeLeaveList employeeLeave in employeeLeaveList)
                {
                    LookUp leaveType = LookUpCodeService.GetLookUpType(employeeLeave.LeaveTypeId);
                    EmployeeLeaveViewModel employeeLeaveViewModel = new EmployeeLeaveViewModel();
                    employeeLeaveViewModel.Id             = employeeLeave.Id;
                    employeeLeaveViewModel.EmployeeName   = employeeLeave.Employee.FirstName + " " + employeeLeave.Employee.LastName;
                    employeeLeaveViewModel.EmployeeId     = employeeLeave.Employee.Id;
                    employeeLeaveViewModel.EmployeeNumber = employeeLeave.Employee.IDNumber;
                    employeeLeaveViewModel.LeaveType      = leaveType.LookUpCode;
                    employeeLeaveViewModel.LeaveTypeId    = leaveType.LookUpID;
                    employeeLeaveViewModel.FromDate       = employeeLeave.FromDate;
                    employeeLeaveViewModel.Days           = employeeLeave.Days;
                    employeeLeaveViewModel.ToDate         = employeeLeave.ToDate;
                    employeeLeaveViewModel.ApplyDate      = employeeLeave.ApplyDate;
                    employeeLeaveViewModel.Status         = employeeLeave.Status;
                    employeeLeaveViewModel.Reason         = employeeLeave.Reason;
                    employeeLeaveViewModel.Remarks        = employeeLeave.Remarks;
                    employeeLeaveViewModel.BranchId       = employeeLeave.BranchId;
                    employeeLeaveViewModel.TeamLeadId     = employeeLeave.ManagerId;
                    employeeLeaveViewModelList.Add(employeeLeaveViewModel);
                }
                if (employeeLeaveViewModelList != null && employeeLeaveViewModelList.Any())
                {
                    result = Json(new { employeeLeaveList = employeeLeaveViewModelList, sucess = true }, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    result = Json(new { sucess = false, message = "No Data Found." }, JsonRequestBehavior.AllowGet);
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    return(Json(new { success = false, message = ex.InnerException.Message }, JsonRequestBehavior.DenyGet));
                }
            }
            return(result);
        }