public IActionResult OrderHistory(StoreViewModel model)
        {
            model.ID           = storeLoggedIn;
            model.StoreName    = _repo.GetStore(model.ID).Name;
            model.OrderHistory = new List <OrderViewClass>();

            bool submitClicked = Request.Form["submit"].ToString() != "";
            bool backClicked   = Request.Form["back"].ToString() != "";

            if (submitClicked && backClicked)
            {
                model.ReasonForError = "There was a problem processing your request. Please try again.";
                return(View("OrderHistory", model));
            }
            else if (backClicked)
            {
                return(Redirect("/Store/Store"));
            }

            if (model.OptionSelected != 1 && model.OptionSelected != 2)
            {
                model.ReasonForError = "There was an error processing your request. Please try again.";
                return(View("OrderHistory", model));
            }

            List <OrderModel> orders;

            if (model.OptionSelected == 1)
            {
                orders = _repo.GetOrdersForStore(model.ID);
            }
            else // if model.OptionSelected == 2
            {
                int parsedUserID;
                if (!int.TryParse(model.FilterHistoryToUser, out parsedUserID))
                {
                    model.ReasonForError = "Please enter a positive integer for a user ID";
                    return(View("OrderHistory", model));
                }
                orders = _repo.GetOrdersForStoreAndUser(model.ID, parsedUserID);
            }

            foreach (OrderModel order in orders)
            {
                StringBuilder toppings = new StringBuilder();
                foreach (string topping in order.Toppings.Split(','))
                {
                    int toppingID;
                    if (!int.TryParse(topping, out toppingID))
                    {
                        Console.WriteLine($"Database error: Expected integer for pizza ID, received {topping}");
                        toppings.Append("Error, ");
                        continue;
                    }
                    ToppingModel top = _repo.GetTopping(toppingID);
                    toppings.Append($"{top.Name}, ");
                }
                toppings.Remove(toppings.Length - 2, 2);
                OrderViewClass orderView = new OrderViewClass {
                    UserID    = order.UserID,
                    OrderID   = order.OrderID,
                    Created   = order.Created,
                    Size      = order.Size,
                    Crust     = _repo.GetCrust(order.CrustID).Name,
                    Toppings  = toppings.ToString(),
                    Quantity  = order.Quantity,
                    Cost      = order.TotalCost,
                    StoreName = _repo.GetStore(order.StoreID).Name
                };
                if (order.PizzaID == 0)
                {
                    orderView.Pizza = "Custom";
                }
                else
                {
                    try {
                        orderView.Pizza = _repo.GetPizza(order.PizzaID).Name;
                    } catch (NullReferenceException) {
                        Console.WriteLine($"Database error: Could not find a pizza with ID {order.PizzaID} in the Pizza table");
                        orderView.Pizza = "Error";
                    }
                }
                model.OrderHistory.Add(orderView);
            }

            model.ReasonForError = $"{model.OrderHistory.Count()} records found";
            return(View("OrderHistory", model));
        }