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); }
public JsonResult GetGrantLeaves() { JsonResult result = null; try { List <LeaveHeader> leaveHeaders = GrantLeaveService.GetAll <LeaveHeader>().ToList(); List <LeaveHeaderViewModel> LeaveHeaderVMList = new List <LeaveHeaderViewModel>(); List <LookUp> LeaveTypeLookUp = LookUpCodeService.GetLookUp <LookUp>(l => l.LookUpCategory == "LeaveType").ToList(); foreach (LeaveHeader leaveHeader in leaveHeaders) { LeaveHeaderViewModel LeaveHeaderVM = new LeaveHeaderViewModel() { Id = leaveHeader.Id, BranchId = leaveHeader.BranchID, LeaveSchemeType = leaveHeader.LeaveSchemeType, LeaveSchemeTypeDescription = LookUpCodeService.GetLookUp <LookUp>(l => l.LookUpID == leaveHeader.LeaveSchemeType).Select(s => s.LookUpCode).FirstOrDefault(), LeaveYear = leaveHeader.LeaveYear, LeaveYearType = LookUpCodeService.GetLookUp <LookUp>(l => l.LookUpID == leaveHeader.LeaveYear).Select(l => l.LookUpCode).FirstOrDefault(), PeriodicityType = leaveHeader.PeriodicityType, PeriodicityTypeDescription = LookUpCodeService.GetLookUp <LookUp>(l => l.LookUpID == leaveHeader.PeriodicityType).Select(l => l.LookUpCode).FirstOrDefault(), PeriodType = leaveHeader.PeriodType, PeriodTypeDescription = LookUpCodeService.GetLookUp <LookUp>(l => l.LookUpID == leaveHeader.PeriodType).Select(l => l.LookUpCode).FirstOrDefault(), }; PrepareleavedetailsViewModel(leaveHeader, LeaveHeaderVM, LeaveTypeLookUp); LeaveHeaderVMList.Add(LeaveHeaderVM); } result = Json(new { sucess = true, LeaveHeaderVMList = LeaveHeaderVMList }, 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); }