public IActionResult CreateCarType(CarsCreateCarModelVM carTypeModel)
        {
            bool status = carsService.CreateCarType(carTypeModel);
            CarsCreateUpdateVM model = carsService.PrepareDataForCreateCars();

            return(RedirectToAction("Create"));
        }
Beispiel #2
0
        public bool CreateCarType(CarsCreateCarModelVM model)
        {
            CarModel carModel = new CarModel
            {
                Name       = model.Name,
                CarBrandId = model.CarBrandId
            };

            context.CarModel.Add(carModel);
            context.SaveChanges();
            return(true);
        }
Beispiel #3
0
        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));
        }