public ActionResult PlanSearching(PlanSearchViewModel model, int page = 1) { const int pageSize = 20; var query = PlanLogService.GetALL().Include(x => x.AddMember) .Include(x => x.CustomerCompany); if (CookieHelper.CheckPermission("boss")) { if (!string.IsNullOrEmpty(model.UserName)) { query = query.Where(x => x.AddMember.NickName.Contains(model.UserName)); } } else if (CookieHelper.CheckPermission("manager")) { var memberIds = MemberService.GetMemberIDs(CookieHelper.GetDepartmentID()); if (!string.IsNullOrEmpty(model.UserName)) { query = query.Where(x => x.AddMember.NickName.Contains(model.UserName) && memberIds.Contains(x.AddUser)); } else { query = query.Where(x => memberIds.Contains(x.AddUser)); } } else { query = query.Where(x => x.AddUser == CookieHelper.MemberID); } var totalCount = query.Count(); var data = query.OrderByDescending(x => x.AddTime).Skip((page - 1) * pageSize).Take(pageSize).ToList(); ViewBag.PageInfo = new PagingInfo() { TotalItems = totalCount, CurrentPage = page, ItemsPerPage = pageSize }; return PartialView(data); }
public ActionResult PlanSearch() { PlanSearchViewModel model = new PlanSearchViewModel(); return View(model); }