示例#1
0
        public async Task <PagedList <EOP> > GetPaginated(EOPParams eOPParams, int?userCommodityId, int?StateId)
        {
            var entities = from f in  Context.EOPs select f;

            entities = userCommodityId == null ? entities : entities.Where(c => c.CommodityId == userCommodityId);
            entities = entities.OrderByDescending(u => u.Id).AsQueryable();



            return(await PagedList <EOP> .CreateAsync(entities, eOPParams.PageNumber, eOPParams.PageSize));
        }
示例#2
0
        public async Task <IActionResult> Get([FromQuery] EOPParams eOPParams)
        {
            ClaimsPrincipal currentUser = _contextAccessor.HttpContext.User;


            if (currentUser.HasClaim(c => c.Type == "State"))
            {
                StateId = int.Parse(currentUser.Claims.FirstOrDefault(c => c.Type == "State").Value);
            }

            if (currentUser.HasClaim(c => c.Type == "Commodity"))
            {
                CommodityId = int.Parse(currentUser.Claims.FirstOrDefault(c => c.Type == "Commodity").Value);
            }

            var entities = await _eOPService.GetPaginated(eOPParams, CommodityId, StateId);

            var entitiesToReturn = _mapper.Map <IEnumerable <EOPForListDTO> >(entities);

            Response.AddPagination(entities.CurrentPage, entities.PageSize,
                                   entities.TotalCount, entities.TotalPages);

            return(Ok(entitiesToReturn));
        }