public IActionResult CreateCarType(CarsCreateCarModelVM carTypeModel) { bool status = carsService.CreateCarType(carTypeModel); CarsCreateUpdateVM model = carsService.PrepareDataForCreateCars(); return(RedirectToAction("Create")); }
public bool CreateCarType(CarsCreateCarModelVM model) { CarModel carModel = new CarModel { Name = model.Name, CarBrandId = model.CarBrandId }; context.CarModel.Add(carModel); context.SaveChanges(); return(true); }
public CarsCreateCarModelVM PrepareDataForCreateCarType() { CarsCreateCarModelVM model = new CarsCreateCarModelVM { carBrandsList = context.CarBrand.Select(x => new SelectListItem { Value = x.CarBrandId.ToString(), Text = x.Name }).ToList() }; return(model); }
public IActionResult CreateCarType() { CarsCreateCarModelVM model = carsService.PrepareDataForCreateCarType(); return(View(model)); }