public void RemoveCustomer(int id) { const string deleted = "Deleted"; OrderService os = new OrderService(); var customer = deckelShopContext.Customers.SingleOrDefault(c => c.Id == id); var customerList = os.GetAllOrdersBySelectedCustomer(id); if (customerList != null) { customer.FirstName = deleted; customer.LastName = deleted; customer.Phone = deleted; customer.City = deleted; customer.Email = deleted; customer.Street = deleted; customer.ZipCode = deleted; } else { deckelShopContext.Customers.Remove(customer); } deckelShopContext.SaveChanges(); }
public void UpdateStockWhenCancelledOrder(int orderId) { var order = _os.GetOrder(orderId); foreach (var item in order.OrderedItems) { deckelShopContext.Products.SingleOrDefault(p => p.Id == item.ProductId).Amount += item.Amount; } deckelShopContext.SaveChanges(); }
public void AddOrder(Order order) { deckelShopContext.Orders.Add(order); deckelShopContext.SaveChanges(); int a = 0; }