public async Task <IActionResult> Edit(CarDetailsEditViewModel input) { if (!this.ModelState.IsValid) { return(this.View(input)); } await this.carsService.EditCar(input); return(this.RedirectToAction("Details", "Cars", new { carId = input.Id })); }
public async Task <IActionResult> EditCar(CarDetailsEditViewModel input) { if (!this.ModelState.IsValid) { return(this.View(input)); } await this.carsService.EditCar(input); return(this.RedirectToAction("Index", "ManageCars", new { area = "Administration" })); }
public async Task EditCar(CarDetailsEditViewModel input) { var carToEdit = this.carRepository .All() .FirstOrDefault(c => c.Id == input.Id); if (input.MainImage != null) { var carMainImageUrl = await CloudinaryExtension.UploadFileAsync(this.cloudinary, input.MainImage); carToEdit.MainImageUrl = carMainImageUrl; } carToEdit.Model = input.Model; carToEdit.Year = input.Year; carToEdit.Horsepower = input.Horsepower; carToEdit.Torque = input.Torque; carToEdit.Weight = input.Weight; carToEdit.TopSpeed = input.TopSpeed; await this.carRepository.SaveChangesAsync(); }