public IActionResult Edit(int id) { Dealership dealership = service.GetOneDealership(id); DealershipEditViewModel model = new DealershipEditViewModel { DealershipId = dealership.DealershipId, Name = dealership.Name, Country = dealership.Country, Town = dealership.Town, Cars = dealership.Cars }; return(View(model)); }
public void UpdateDealership(DealershipEditViewModel entity) { Dealership dealership = context.Dealerships.Find(entity.DealershipId); if (dealership is null) { return; } dealership.Name = entity.Name; dealership.Country = entity.Country; dealership.Town = entity.Town; dealership.Cars = entity.Cars; context.Dealerships.Update(dealership); context.SaveChanges(); }
public IActionResult Edit(DealershipEditViewModel entity) { service.UpdateDealership(entity); return(Redirect("/")); }