public IActionResult Edit(InputBreweryEditModel model) { if (ModelState.IsValid) { this.breweryService.Edit(model); } return(RedirectToAction(nameof(this.Index))); }
public bool Edit(InputBreweryEditModel model) { // TODO: Add Validation for State City BreweryType ... var entity = this.db.Breweries.FirstOrDefault(x => x.Id == model.Id); if (entity == null) { return(false); } entity.Name = model.Name; entity.Street = model.Street; entity.PostalCode = model.PostalCode; entity.StateId = this.statesService.GetIdByName(model.State); entity.CityId = this.citiesService.GetIdByName(model.City); entity.BreweryTypeId = this.breweryTypeService.GetIdByName(model.Status); entity.Url = model.Url; this.db.Breweries.Update(entity); this.db.SaveChanges(); return(true); }