Exemplo n.º 1
0
        public ActionResult Edit(int id, IFormCollection collection)
        {
            try
            {
                var c = GetCustomerById(id);
                c.Name = collection["Name"];
                TryValidateModel(c);

                _context.Update(c);
                _context.SaveChanges();

                return(RedirectToAction(nameof(List)));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 2
0
        public ActionResult Edit(int id, IFormCollection collection)
        {
            try
            {
                var s = GetServiceById(id);
                s.Name = collection["Name"];
                s.Cost = System.Convert.ToInt32(collection["Cost"]);
                TryValidateModel(s);

                _context.Update(s);
                _context.SaveChanges();

                return(RedirectToAction(nameof(List)));
            }
            catch
            {
                return(View());
            }
        }