Exemple #1
0
        public ActionResult Create(Customer customer)
        {
            if (ModelState.IsValid)
            {
                db.Customers.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(RedirectToAction("Index"));
        }
        public Customer CreateCustomer(Customer customer)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            db.Customers.Add(customer);
            db.SaveChanges();

            return(customer);
        }
Exemple #3
0
        public Product CreateProduct(Product product)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            db.Products.Add(product);
            db.SaveChanges();

            return(product);
        }
        public Store CreateStore(Store store)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            db.Stores.Add(store);
            db.SaveChanges();

            return(store);
        }