コード例 #1
0
        public async Task OnGet()
        {
            Data = await Mediator.Send(new GetTopCarAds());

            BrandsListViewModel      = new BrandsListViewModel();
            BrandsListViewModel.Data = _context.Brands.ToList();


            //var a = await Mediator.Send(new GetCarAdsShortViewByBrand { searchModel = new CarAdSearchModel(r => r.Name.Contains("Lex")) });
        }
コード例 #2
0
        //public ActionResult Index(int i = 1)
        //{
        //    int Total,size=6;
        //    List<AppCar> b = unit.GetAllCars(i,size,out Total).Select(x => x.FromDomainCarToRepoCar()).ToList();
        //    PageInfo page = new PageInfo { PageSize = size, PageNumber = i, TotalItems = Total};
        //    IndexViewModel index = new IndexViewModel { PageInfo = page, Cars = b };
        //    return View(index);
        //}

        public ActionResult Index(int i = 1, string brand = "Все")
        {
            int           Total, size = 6;
            List <AppCar> b    = unit.GetAllCars(i, size, brand, out Total).Select(x => x.FromDomainCarToRepoCar()).ToList();
            PageInfo      page = new PageInfo {
                PageSize = size, PageNumber = i, TotalItems = Total
            };
            IndexViewModel index = new IndexViewModel {
                PageInfo = page, Cars = b
            };
            List <string> CarBrands = unit.GetAllBrands().Select(x => x.FromAppBrandToBrand()).ToList();

            CarBrands.Insert(0, "Все");
            BrandsListViewModel brands = new BrandsListViewModel {
                PageInfo = page, Cars = b, Brands = new SelectList(CarBrands)
            };

            return(View(brands));
        }