Ejemplo n.º 1
0
        public PagedCollection <Tank> GetNumberItems(Func <Tank, bool> predicate, int page = 1, int pageSize = 20)
        {
            int totalitems = db.Tanks.Where(predicate).Count();

            if ((int)Math.Ceiling((decimal)totalitems / pageSize) < page)
            {
                page = 1;
            }
            ;
            IEnumerable <Tank> tanks    = db.Tanks.Where(predicate).OrderBy(o => o.TankID).Skip((page - 1) * pageSize).Take(pageSize);
            PageInfo           pageInfo = new PageInfo {
                PageNumber = page, PageSize = pageSize, TotalItems = totalitems
            };
            PagedCollection <Tank> viewtanks = new PagedCollection <Tank> {
                PageInfo = pageInfo, PagedItems = tanks
            };

            return(viewtanks);
        }
Ejemplo n.º 2
0
        public PagedCollection <Operation> GetNumberItems(Func <Operation, bool> predicate, int page = 1, int pageSize = 20)
        {
            int totalitems = db.Operations.Where(predicate).Count();

            if ((int)Math.Ceiling((decimal)totalitems / pageSize) < page)
            {
                page = 1;
            }
            ;
            IEnumerable <Operation> operations = db.Operations.OrderBy(o => o.OperationID).Skip((page - 1) * pageSize).Take(pageSize).Include(o => o.Fuel).Include(o => o.Tank).Where(predicate);
            PageInfo pageInfo = new PageInfo {
                PageNumber = page, PageSize = pageSize, TotalItems = totalitems
            };
            PagedCollection <Operation> viewoperations = new PagedCollection <Operation> {
                PageInfo = pageInfo, PagedItems = operations
            };

            return(viewoperations);
        }
Ejemplo n.º 3
0
        public PagedCollection <Fuel> GetNumberItems(Func <Fuel, bool> predicate, int page = 1, int pageSize = 20)
        {
            IEnumerable <Fuel> fuels = db.Fuels.Where(predicate).OrderBy(o => o.FuelID);
            int totalitems           = fuels.Count();

            if ((int)Math.Ceiling((decimal)totalitems / pageSize) < page)
            {
                page = 1;
            }
            ;
            if (page != 0)
            {
                fuels = fuels.Skip((page - 1) * pageSize).Take(pageSize);
            }
            ;
            PageInfo pageInfo = new PageInfo {
                PageNumber = page, PageSize = pageSize, TotalItems = totalitems
            };
            PagedCollection <Fuel> viewfuels = new PagedCollection <Fuel> {
                PageInfo = pageInfo, PagedItems = fuels
            };

            return(viewfuels);
        }