Esempio n. 1
0
        public ActionResult Add(IFormCollection collection)
        {
            try
            {
                var customerID = System.Convert.ToInt32(collection["customer"]);
                var serviceID  = System.Convert.ToInt32(collection["service"]);

                _context.Add(new ServiceContract(customerID, serviceID));
                _context.SaveChanges();

                return(RedirectToAction(nameof(List)));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 2
0
        public ActionResult Add(IFormCollection collection)
        {
            try
            {
                var c = new Customer {
                    Name = collection["Name"]
                };
                TryValidateModel(c);

                _context.Add(c);
                _context.SaveChanges();

                return(RedirectToAction(nameof(List)));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 3
0
        public ActionResult Add(IFormCollection collection)
        {
            try
            {
                var s = new Service
                {
                    Name = collection["Name"],
                    Cost = System.Convert.ToInt32(collection["Cost"])
                };
                TryValidateModel(s);

                _context.Add(s);
                _context.SaveChanges();

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