public JsonResult GetLeaveList(int?pageNo, int?pageSize, string isSearching, LeaveSearchOptions Options) { bool IsSearching = Convert.ToBoolean(isSearching); LeaveListPageModal pagedList = leaveManagement.GetLeavePageList(pageNo, pageSize, IsSearching, Options); return(Json(pagedList, JsonRequestBehavior.AllowGet)); }
public List <LEAVE> ApplySearchOption(List <LEAVE> listLeave, LeaveSearchOptions Options) { int LeaveTypeId = Convert.ToInt32(Options.Leavetype); int StatusId = Convert.ToInt32(Options.Status); if (Options.Name != null && Options.Name != String.Empty) { var leavesAction = NCSSEntities.LEAVEMODIFies.Where(p => p.Action == ACTION_TYPE.Submit && p.USER.FullName.Contains(Options.Name)).Select(u => u.LeaveId).ToList(); listLeave = listLeave.Where(p => leavesAction.Contains(p.LeaveId)).ToList(); } if (Options.Leavetype != null && Options.Leavetype != String.Empty && Options.Leavetype != "-1") { listLeave = listLeave.Where(p => p.LeaveTypeId == LeaveTypeId).ToList(); } if (Options.Status != null && Options.Status != String.Empty && Options.Status != "-1") { listLeave = listLeave.Where(p => p.LeaveStatusId == StatusId).ToList(); } return(listLeave); }
public LeaveListPageModal GetLeavePageList(int?pageNo, int?pageSize, bool isSearching, LeaveSearchOptions Options) { return(LeaveAccess.GetLeavePageList(pageNo, pageSize, isSearching, Options)); }
public LeaveListPageModal GetLeavePageList(int?pageNo, int?pageSize, bool isSearching, LeaveSearchOptions Options) { LeaveListPageModal Page = new LeaveListPageModal(); var LeaveRepository = NCSSEntities.LEAVEs.ToList(); if (isSearching == true) { LeaveRepository = ApplySearchOption(LeaveRepository, Options); } List <LeaveListItem> listLeave = new List <LeaveListItem>(); LeaveRepository.ForEach(p => listLeave.Add( new LeaveListItem { Id = p.LeaveId.ToString(), DateFrom = p.DateFrom.ToString(), DateTo = p.DateTo.ToString(), DaysOff = p.DaysOff ?? 0, Reason = p.Reason, LeaveType = p.LEAVETYPE.LeaveName, Status = p.LEAVESTATU.LeaveStatusName, SubmitBy = p.LEAVEMODIFies.Where(u => u.Action == ACTION_TYPE.Submit).FirstOrDefault().USER.FullName } )); int pageTakeSize = pageSize ?? 10; int pageCount = (LeaveRepository.Count() % pageTakeSize == 0) ? LeaveRepository.Count() / pageTakeSize : (LeaveRepository.Count() / pageTakeSize + 1); int pageNumber = pageNo ?? 1; pageNumber = pageNumber <= pageCount ? pageNumber : pageCount; pageNumber = pageNo <= 0 ? 1 : pageNumber; int skipItem = (pageNumber - 1) * pageTakeSize; Page.LeaveList = listLeave.OrderBy(p => p.Id).Skip(skipItem).Take(pageTakeSize).ToList(); Page.CurrentPage = pageNumber; Page.PageCount = pageCount; Page.PageSize = pageTakeSize; Page.TotalCount = LeaveRepository.Count(); return(Page); }