public async Task <IActionResult> EditBike(EditBikeInputModel input, int id) { if (!this.ModelState.IsValid) { return(this.View()); } await this.motorBikesService.EditBikeAsync(input, id); return(this.RedirectToAction(nameof(this.Success))); }
public async Task EditBikeAsync(EditBikeInputModel input, int id) { var bike = this.motorBikeRepository.All().FirstOrDefault(x => x.Id == id); bike.Name = input.Name; bike.Model = input.Model; bike.Price = input.Price; bike.Weight = input.Weight; bike.Length = input.Length; bike.Height = input.Height; bike.SeatHeight = input.SeatHeight; bike.BikeType = new BikeType { Name = input.BikeType }; bike.BikeType.Descrition = input.BikeTypeDesctiption; bike.Engine = new Engine { Name = input.EngineName, EnginePower = input.EnginePower, EngineCapacity = input.EngineCapacity, CoolingSystem = new CoolingSystem { Name = input.CoolingSystem } }; bike.Transmission = new Transmission { Name = input.Transmission }; bike.FrontSuspension = new FrontSuspension { Name = input.FrontSuspension }; bike.RearSuspension = new RearSuspension { Name = input.RearSuspension }; bike.FrontBrakes = new FrontBrake { Name = input.FrontBrakes }; bike.RearBrakes = new RearBrake { Name = input.RearBrakes }; bike.Descrition = input.Descrition; bike.ModifiedOn = DateTime.UtcNow; await this.motorBikeRepository.SaveChangesAsync(); }