Exemple #1
0
 public async static Task DeleteProductPrice(ProductPrice itemPara)
 {
     using (var db = new SalesContext())
     {
         //if (itemPara.Store != null)                                   //NOT DELETE - IMPORTANT
         //    db.Stores.Attach(itemPara.Store);
         //if (itemPara.Product != null)                                   //NOT DELETE - IMPORTANT
         //    db.Products.Attach(itemPara.Product);
         db.Entry(itemPara).State = EntityState.Unchanged;                       //NOT DELETE - IMPORTANT
         ProductPrices.Remove(itemPara);
         db.Entry(itemPara).State = EntityState.Deleted;
         await UpdateDatabase(db);
     }
 }
Exemple #2
0
 public async static Task DeleteAllProductPrices(ICollectionView itemParas)
 {
     using (var db = new SalesContext())
     {
         List <ProductPrice> list = new List <ProductPrice>();
         foreach (object item in itemParas)
         {
             list.Add((ProductPrice)item);
         }
         foreach (ProductPrice item in list)
         {
             db.Entry(item).State = EntityState.Unchanged;
             ProductPrices.Remove(item);
             db.Entry(item).State = EntityState.Deleted;
             //Categories.Remove(item);
             //var query = db.Categories.Find(item.Id);
             //db.Entry(query).State = EntityState.Deleted;
         }
         await UpdateDatabase(db);
     }
 }