예제 #1
0
        public async Task <PagingDataSource <Staff> > Get(ODataQueryOptions <Staff> options, [FromUri] StaffList req)
        {
            StaffService.DisableProxy();

            var litStaff = StaffService.GetAll();

            if (req != null)
            {
                if (req.Includes != null && req.Includes.Length > 0)
                {
                    litStaff = Include(litStaff, req.Includes);
                }

                if (req.PositionId > 0)
                {
                    litStaff = litStaff.Where(o => o.PositionId == req.PositionId);
                }
            }

            var ls = (IQueryable <Staff>)options.ApplyTo(litStaff);

            var retVal = new PagingDataSource <Staff>();

            retVal.Data = await ls.Cast <Staff>().ToListAsync();

            retVal.Total = Request.GetInlineCount() ?? 0;

            return(retVal);
        }