public ActionResult EditMarket(AdminMarketsPlaces_EditMarketViewModel model) { if (ModelState.IsValid) { var market = db.Markets.FirstOrDefault(m => m.Id == model.MarketId); market.Name = model.MarketName; market.Latitude = model.Latitude; market.Longitude = model.Longitude; db.Entry(market).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("MarketDetails", new { id = model.MarketId })); } return(View(model)); }
public ActionResult EditMarket(int?id) { if (id is null) { return(View("Error")); } var market = db.Markets.FirstOrDefault(m => m.Id == id); if (market is null) { return(View("Error")); } var model = new AdminMarketsPlaces_EditMarketViewModel { MarketId = market.Id, MarketName = market.Name, Latitude = market.Latitude, Longitude = market.Longitude }; return(View(model)); }