public void DeleteProduct(int id) { using (var context = new OMContext()) { var product = context.Products.Find(id); context.Products.Remove(product ?? throw new InvalidOperationException()); context.SaveChanges(); } }
public void UpdateProduct(Product product) { using (var context = new OMContext()) { //context.Categories.AddOrUpdate(category); context.Entry(product).State = EntityState.Modified; context.SaveChanges(); } }
public void ProductSave(Product product) { using (var context = new OMContext()) { context.Entry(product.Category).State = EntityState.Unchanged; context.Products.Add(product); context.SaveChanges(); } }
public bool UpdateOrderStatus(int ID, string status) { using (var context = new OMContext()) { var order = context.Orders.Find(ID); order.Status = status; context.Entry(order).State = EntityState.Modified; return(context.SaveChanges() > 0); } }
public int SaveOrder(Order order) { _context.Orders.Add(order); return(_context.SaveChanges()); }
public void CategorySave(Category category) { _context.Categories.Add(category); _context.SaveChanges(); }