public ActionResult Edit(Guid id, IFormCollection collection) { try { Models.Soda soda = sodas.FirstOrDefault(x => x.Id.Equals(id)); soda.Brand = collection["Brand"]; soda.Quantity = int.Parse(collection["Quantity"]); soda.Price = int.Parse(collection["Price"]); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ActionResult Create(IFormCollection collection) { try { Models.Soda soda = new Models.Soda(); soda.Id = Guid.NewGuid(); soda.Brand = collection["Brand"]; soda.Quantity = int.Parse(collection["Quantity"]); soda.Price = int.Parse(collection["Price"]); sodas.Add(soda); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }