public IActionResult BrandModelsList([FromRoute] int brandId = 0, int page = 1, [FromRoute] int pagesize = 10) { if (brandId != 0) { return(PartialView("_BrandModelsList", _bmRepo.GetAllBrandModels().Where(bm => bm.BrandId == brandId).ToList().ToPagedList(page, pagesize))); } else { return(PartialView("_BrandModelsList", _bmRepo.GetAllBrandModels().ToPagedList(page, pagesize))); } }
public AddCarModel(IVehicleTypeRepository _vehicleTypeRepo, ICarRepository _carRepo, IBrandRepository _brandRepo, IBrandModelRepository _brandModelRepo, IWebHostEnvironment _hostEnvironment, UserManager <ApplicationUser> _userManager ) { this.vehicleTypeRepo = _vehicleTypeRepo; this.carRepo = _carRepo; this.brandRepo = _brandRepo; this.brandModelRepo = _brandModelRepo; this.hostEnvironment = _hostEnvironment; this.userManager = _userManager; this.VehicleTypes = new SelectList(vehicleTypeRepo.GetAllVehicleTypes().OrderBy(vt => vt.Type), "Id", "Type"); this.Brands = new SelectList(brandRepo.GetAllBrands().OrderBy(b => b.Name), "Id", "Name"); this.BrandModels = new SelectList(brandModelRepo.GetAllBrandModels().Where(bm => bm.BrandId == brandRepo.GetAllBrands().OrderBy(b => b.Name).FirstOrDefault().Id).OrderBy(b => b.Name), "Id", "Name"); this.OdoMeters = new SelectList(carRepo.Context.OdoMeters.ToList(), "Id", "Value"); this.Colors = new SelectList(carRepo.Context.Colors.OrderBy(c => c.Name).ToList(), "Id", "Name"); this.Vehicle = new Vehicle(); this.Cities = new SelectList(carRepo.Context.Cities.OrderBy(c => c.Name).ToList(), "Id", "Name"); this.Today = DateTime.Now.Date; }
public void OnGet(int id) { Vehicle = carRepo.GetVehicle(id); BrandModels = new SelectList(brandModelRepo.GetAllBrandModels().Where(bm => bm.BrandId == Vehicle.Model.BrandId).OrderBy(b => b.Name), "Id", "Name"); }
public void OnGet() { BrandsSelectList = new SelectList(_brandRepo.GetAllBrands().OrderBy(b => b.Name), "Id", "Name"); Request.Query.TryGetValue("entries", out var entries); Request.Query.TryGetValue("vehiclePage", out var vehiclePage); Request.Query.TryGetValue("VTypePage", out var VTypePage); Request.Query.TryGetValue("brandPage", out var brandPage); Request.Query.TryGetValue("brandModelPage", out var brandModelPage); Request.Query.TryGetValue("colorPage", out var colorPage); int vehiclesPageNumber = 1; int vTypePageNumber = 1; int brandsPageNumber = 1; int brandModelsPageNumber = 1; int colorPageNumber = 1; if (entries.Count > 0) { if (int.TryParse(entries[0], out var _pageSize)) { PageSize = _pageSize; } } else { PageSize = 5; } if (vehiclePage.Count > 0) { if (int.TryParse(vehiclePage[0], out var pageNum)) { vehiclesPageNumber = pageNum; } } if (brandPage.Count > 0) { if (int.TryParse(brandPage[0], out var pageNum)) { brandsPageNumber = pageNum; } } if (brandModelPage.Count > 0) { if (int.TryParse(brandModelPage[0], out var pageNum)) { brandModelsPageNumber = pageNum; } } if (VTypePage.Count > 0) { if (int.TryParse(VTypePage[0], out var pageNum)) { vTypePageNumber = pageNum; } } if (colorPage.Count > 0) { if (int.TryParse(colorPage[0], out var pageNum)) { colorPageNumber = pageNum; } } CurrentVehiclesPage = vehiclesPageNumber; CurrentBrandsPage = brandsPageNumber; CurrentBrandModelsPage = brandModelsPageNumber; CurrentVTypesPage = vTypePageNumber; CurrentColorsPage = colorPageNumber; Vehicles = _carRepository.GetAllVehiclesRequests().OrderByDescending(v => v.Id).ToList().ToPagedList(vehiclesPageNumber, PageSize); Brands = _brandRepo.GetAllBrands().ToList().ToPagedList(brandsPageNumber, PageSize); BrandModels = _brandModelRepo.GetAllBrandModels().ToList().ToPagedList(brandModelsPageNumber, PageSize); VehicleTypes = _vehicleTypeRepo.GetAllVehicleTypes().ToList().ToPagedList(vTypePageNumber, PageSize); Colors = _ColorRepo.GetAllColors().ToList().ToPagedList(colorPageNumber, PageSize); }