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(); }
public void DeleteStatistic(Statistic statistic) { try { context.Statistics.Remove(statistic); context.SaveChanges(); } catch (Exception) { throw; } }
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(); } } }