Пример #1
0
 //[HttpPost]
 public ActionResult Create(Product pro)
 {
     if (ModelState.IsValid)
     {
         db.Products.Add(pro);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(pro));
 }
Пример #2
0
        public bool UpdateCustomer(Product _product)
        {
            try{
                Product updatedproduct = (from c in entities.Products
                                          where c.Id == _product.Id
                                          select c).FirstOrDefault();
                updatedproduct.Name        = _product.Name;
                updatedproduct.Description = _product.Description;
                updatedproduct.price       = _product.price;
                updatedproduct.Quantity    = _product.Quantity;

                entities.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
            }
            return(true);
        }
Пример #3
0
        public Product InsertCustomer(Product _product)
        {
            try{
                using (SignupForm_TestEntities entities = new SignupForm_TestEntities())
                {
                    entities.Products.Add(_product);
                    entities.SaveChanges();
                }

                return(_product);
            }
            catch (Exception ex)
            {
            }
            return(_product);
        }