public IActionResult Create(CarDto carCreateDto) { if (carCreateDto == null) { return(BadRequest()); } var car = new Car(); car.EngineLabel = carCreateDto.EngineLabel; car.FuelType = carCreateDto.FuelType; car.HeaviestCurbWeight = car.HeaviestCurbWeight; car.LightestCurbWeight = car.LightestCurbWeight; car.MaxEngPower = car.MaxEngPower; car.MaxTorqPower = car.MaxTorqPower; car.ModelName = car.ModelName; car.OverallHeight = car.OverallHeight; car.OverallLenght = car.OverallLenght; car.OverallWidth = car.OverallWidth; car.Photo = car.Photo; car.ProductLabel = car.ProductLabel; car.Seats = car.Seats; car.Tires = car.Tires; car.Wheels = car.Wheels; carData.Create(car); carData.Commit(); return(CreatedAtRoute("GetCar", new { id = car.Id }, car)); }
public IActionResult OnPost() { if (ModelState.IsValid) { if (Car.Id == 0 && Photo != null) { Car.Photo = ProcessUploadedFile(); Car = carData.Create(Car); TempData["Message"] = "The Car is creagted."; } carData.Commit(); return(RedirectToPage("./CarModels", new { carId = Car.Id })); } return(Page()); }