public static async Task <IEnumerable <CarModel> > FindModelsByBrandIdAsync(this IOrderedQueryable <CarBrand> brands, int brandId)
        {
            CarBrand brand = await brands
                             .Include(b => b.CarModels).FirstOrDefaultAsync(b => b.Id == brandId);

            return(brand == null ? null : brand.CarModels);
        }
        public static IEnumerable <Car> FindCarsByBrandId(this IOrderedQueryable <Car> carsSet, int brandId)
        {
            IEnumerable <Car> cars = carsSet
                                     .Include(c => c.Model)
                                     .Include(c => c.Model.CarBrand)
                                     .Include(c => c.Color)
                                     .Include(c => c.Owner)
                                     .Where(c => c.Model.BrandId == brandId)
                                     .AsNoTracking();

            return(cars);
        }
Exemplo n.º 3
0
        public ActionResult Index()
        {
            IOrderedQueryable <Payment> orderByDescending = _db.Payments.OrderByDescending(payment => payment.Date);
            IQueryable <Payment>        queryable         = orderByDescending.Include("MenuItem");

            if (Roles.IsUserInRole("Customer"))
            {
                return(View(queryable.Where(payment => payment.UserId == WebSecurity.CurrentUserId)));
            }
            else
            {
                return(View(queryable.Where(payment => payment.MenuItem.UserId == WebSecurity.CurrentUserId)));
            }
        }