Exemplo n.º 1
0
        protected override void RefreshMethod()
        {
            if (!IsFilterInitialized)
            {
                Filter = new StaffFilter();

                IsFilterInitialized = true;
            }

            base.RefreshMethod();
        }
        // GET: api/Staffs
        public IHttpActionResult GetStaff([FromUri] StaffFilter staffFilter)
        {
            IQueryable <Staff> queryable = db.Staffs;

            if (!string.IsNullOrEmpty(staffFilter.SearchTerm))
            {
                string lowerCased = staffFilter.SearchTerm.ToLower();
                queryable = queryable.Where(s =>
                                            s.FirstName.ToLower().Contains(lowerCased) ||
                                            s.LastName.ToLower().Contains(lowerCased)
                                            );
            }
            var staffPage = Pagination.CreatePage <Staff>(
                queryable, staffFilter.Page, staffFilter.PageSize, staffFilter.OrderBy, staffFilter.Ascending, Request
                );

            return(Ok(staffPage));
        }