public void DeletePrice(Price price)
 {
     try
     {
         context.Prices.Remove(price);
         context.SaveChanges();
     }
     catch (Exception)
     {
         throw;
     }
 }
 public void SaveVendor(Vendor vendor)
 {
     if (vendor.VendorID == 0)
     {
         context.Vendors.Add(vendor);
     }
     else
     {
         context.Entry(vendor).State = EntityState.Modified;
     }
     context.SaveChanges();
 }
Esempio n. 3
0
 public void DeleteStatistic(Statistic statistic)
 {
     try
     {
         context.Statistics.Remove(statistic);
         context.SaveChanges();
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 4
0
        public void SaveProduct(Product product)
        {
            Product productOrigin = context.Products.FirstOrDefault(x => x.Code == product.Code);

            if (productOrigin == null)
            {
                //
                product.CreationDate = DateTime.Now.Date;
                context.Products.Add(product);
                context.SaveChanges();
            }
            else
            {
                //  context.Entry(productOrigin).State = EntityState.Detached;
                //context.Products.Attach(productOrigin);
                if (!productOrigin.Equals(product))
                {
                    productOrigin.CloneProduct(product);
                    context.Entry(productOrigin).State = EntityState.Modified;
                    context.SaveChanges();
                }
            }
        }