//public bool SetLocationInventory(int productId, int locationId, int n, bool delta) //{ // return repo.SetLocationInventory(productId, locationId, n, delta); //} public List <Order> GetAllOrders() { List <Order> orders = repo.GetOrders(order => order.CheckoutTimestamp != null); foreach (Order order in orders) { foreach (OrderItem oi in order.orderItems) { oi.Product = repo.GetProductById(oi.ProductId); oi.Location = repo.GetLocationById(oi.LocationId); } } return(orders); }
public void GetOrdersShouldGetAllOrders() { using (var ctx = new StoreContext(options)) { StoreRepoDB repo = new StoreRepoDB(ctx); User user = new User { isManager = false, UserName = "******" }; ctx.Users.Add(user); ctx.SaveChanges(); for (int i = 0; i < 5; i++) { Order testOrder = new Order(); testOrder.UserId = user.UserId; ctx.Orders.Add(testOrder); } ctx.SaveChanges(); } using (var assertCtx = new StoreContext(options)) { StoreRepoDB repo = new StoreRepoDB(assertCtx); var orders = repo.GetOrders(order => true); Assert.NotNull(orders); Assert.Equal(5, orders.Count); } }