public void SaveOrder(Order order) { if (order.OrderId == 0) { _skiHouseDBContext.Orders.Add(order); } _skiHouseDBContext.SaveChanges(); }
public void SaveProduct(Product product) { if (product.ProductId == 0) { _skiHouseDBContext.Products.Add(product); } else { Product dbEntry = _skiHouseDBContext.Products .FirstOrDefault(p => p.ProductId == product.ProductId); if (dbEntry != null) { dbEntry.Name = product.Name; dbEntry.Description = product.Description; dbEntry.Price = product.Price; dbEntry.Category = product.Category; } } _skiHouseDBContext.SaveChanges(); }