//
        // GET: /OA/Staff/

        public ActionResult Index(StaffRequest request)
        {


            var result = this.OAService.GetStaffList(request);
            return View(result);
        }
Exemple #2
0
        public IEnumerable<Staff> GetStaffList(StaffRequest request = null)
        {
            request = request ?? new StaffRequest();
            using (var dbContext = new OADbContext())
            {
                IQueryable<Staff> staffs = dbContext.Staffs.Include("Branch");

                if (!string.IsNullOrEmpty(request.Name))
                    staffs = staffs.Where(u => u.Name.Contains(request.Name));

                if (request.BranchId > 0)
                    staffs = staffs.Where(u => u.BranchId == request.BranchId);

                return staffs.OrderByDescending(u => u.ID).ToPagedList(request.PageIndex, request.PageSize);
            }
        }