示例#1
0
        public void DeleteProduct(int id)
        {
            Product product         = GetProduct(id);
            var     productCatalogs = product.ProductCatalog.ToList();

            foreach (ProductCatalog c in productCatalogs)
            {
                _context.Entry(c).State = EntityState.Deleted;
            }

            _context.Entry(product).State = EntityState.Deleted;
        }
示例#2
0
        public void DeleteCatalog(int id)
        {
            Catalog catalog         = GetCatalog(id);
            var     productCatalogs = catalog.ProductCatalog.ToList();

            foreach (ProductCatalog c in productCatalogs)
            {
                _context.Entry(c).State = EntityState.Deleted;
            }

            _context.Entry(catalog).State = EntityState.Deleted;
        }
 public ActionResult Edit(Catalog catalog)
 {
     if (ModelState.IsValid)
     {
         db.Entry(catalog).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(catalog));
 }
 public ActionResult Edit(Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(product));
 }
示例#5
0
 public void UpdateCatalog(Catalog c)
 {
     using (LocalDbEntities context = new LocalDbEntities())
     {
         var Catalog = context.Catalog.Find(c.Id);
         Catalog.Description = c.Description;
         Catalog.Code        = c.Code;
         context.Catalog.Attach(Catalog);
         context.Entry(Catalog).State = System.Data.EntityState.Modified;
         context.SaveChanges();
     }
 }
示例#6
0
 public void UpdateProduct(Product p)
 {
     using (LocalDbEntities context = new LocalDbEntities())
     {
         var Product = context.Product.Find(p.Id);
         Product.Code        = p.Code;
         Product.Description = p.Description;
         //foreach (var item in p.CatalogProduct)
         //{
         //    var Cp = context.CatalogProduct.Where(w => w.IdProduct == p.Id && w.IdCatalog == item.IdCatalog);
         //    foreach (var sItem in Cp)
         //    {
         //        context.CatalogProduct.Remove(sItem);
         //    }
         //}
         //Product.CatalogProduct = p.CatalogProduct;
         context.Entry <Product>(Product);
         context.SaveChanges();
     }
 }
示例#7
0
 public int SaveModifed(Catalog catalog)
 {
     _context.Entry(catalog).State = EntityState.Modified;
     return(_context.SaveChanges());
 }
示例#8
0
 public int SaveModifed(Product product)
 {
     _context.Entry(product).State = EntityState.Modified;
     return(_context.SaveChanges());
 }