Ejemplo n.º 1
0
        public async Task <IEnumerable <VehicleModel> > GetModelsList(VehicleFilters filter, VehiclePaging page)
        {
            IQueryable <VehicleModel> model = from m in context.VehicleModels.Include(m => m.VehicleMake) select m;

            if (filter.Filters())
            {
                model = model.Where(v => v.Name.Contains(filter.FilterBy) || v.Abrv.Contains(filter.FilterBy) || v.VehicleMake.Name.Contains(filter.FilterBy));
            }
            page.TotalItems = model.Count();
            return(await model.OrderBy(m => m.Name).Skip(page.Skip).Take(page.PageSize).ToListAsync());
        }
Ejemplo n.º 2
0
        public async Task <IEnumerable <VehicleMake> > GetMakesList(VehicleFilters filter, VehiclePaging pageing)
        {
            IQueryable <VehicleMake> makes = from make in context.VehicleMakes select make;

            if (filter.Filters())
            {
                makes = makes.Where(m => m.Name.Contains(filter.FilterBy) || m.Abrv.Contains(filter.FilterBy));
            }
            pageing.TotalItems = makes.Count();
            return(await makes.OrderBy(m => m.Name).Skip(pageing.Skip).Take(pageing.PageSize).ToListAsync());
        }