Exemple #1
0
        public LocationOrdersVM GetLocationOrdersVM(int?LocationID, int?SortBy)
        {
            var locationOrdersVM = new LocationOrdersVM();

            if (LocationID != null)
            {
                locationOrdersVM.LocationID = LocationID.Value;
                var orders = GetLocationOrders(locationOrdersVM.LocationID);
                foreach (var order in orders)
                {
                    var orderVM = new OrderVM()
                    {
                        CustomerID    = order.CustomerID,
                        CustomerName  = order.Customer.Name,
                        LocationID    = order.LocationID,
                        LocationName  = order.Location.LocationName,
                        State         = order.Location.State,
                        OrderDateTime = order.OrderDateTime,
                        Total         = order.Total
                    };
                    if (order.DrinkOrders != null)
                    {
                        foreach (var drinkOrder in order.DrinkOrders)
                        {
                            var drinkOrderVM = new DrinkOrderVM
                            {
                                DrinkId   = drinkOrder.DrinkId,
                                DrinkName = drinkOrder.Drink.DrinkName,
                                ABV       = drinkOrder.Drink.ABV,
                                Quantity  = drinkOrder.Quantity,
                                Price     = drinkOrder.Drink.Price
                            };
                            orderVM.DrinkOrders.Add(drinkOrderVM);
                        }
                    }


                    locationOrdersVM.Orders.Add(orderVM);
                }
            }
            if (SortBy != null)
            {
                locationOrdersVM.SortBy = SortBy.Value;
            }
            locationOrdersVM.Orders = SortOrders(locationOrdersVM.SortBy, locationOrdersVM.Orders);
            return(locationOrdersVM);
        }
 public IActionResult SearchLocationOrders(LocationOrdersVM locationOrdersVM)
 {
     return(RedirectToAction("LocationOrders", "Order", new { LocationID = locationOrdersVM.LocationID, SortBy = locationOrdersVM.SortBy }));
 }