Exemple #1
0
        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());
            }
        }
Exemple #2
0
        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());
            }
        }