public IActionResult Index(ViewOrderHistoryModel model)
        {
            _logger.LogInformation("Store Controller: PostIndex");

            string SearchOrder           = model.SearchOrder;
            string SearchOrderDetail     = model.SearchOrderDetail;
            string SearchCustomerHistory = model.SearchCustomerHistory;



            var y = _repo.GetAllOrders();

            if (SearchOrder != null)
            {
                var orderStoreHistory = y.Where(a => a.Store.StoreID == int.Parse(SearchOrder));
                var xx = orderStoreHistory.ToList();
                model.Order = (xx);
            }
            if (SearchOrderDetail != null)
            {
                var orderDetail = y.Where(a => a.Id == int.Parse(SearchOrderDetail)).FirstOrDefault();
                var xx          = orderDetail;
                model.OrderDetail = (xx);
            }
            if (SearchCustomerHistory != null)
            {
                var orderDetail = y.Where(a => a.Customer.Username == SearchCustomerHistory);
                var xx          = orderDetail.ToList();
                model.CusOrdHistory = (xx);
            }


            return(View(model));
        }
        public IActionResult FinishOrder()
        {
            _logger.LogInformation("AddToCart Controller: GetFinishOrder");
            ViewOrderDetailsModel od = new ViewOrderDetailsModel();

            od.Product = DeserObjectOrderDetail(TempData["OrderDetail"].ToString());
            od.Date    = DateTime.Now;
            od.store   = DeserObjectStore(TempData["Store"].ToString());

            Order o = new Order();

            o.Product = od.Product;
            o.Store   = od.store;
            try
            {
                var allC = _repo.GetAllCustomer().Where(c => c.Username == TempData.Peek("Logged").ToString()).FirstOrDefault();
                o.Customer = allC;

                _repo.AddOrder(o);
                var allOrder = _repo.GetAllOrders().Count();
                foreach (Product x in od.Product.Keys)
                {
                    _repo.AddOrderDetail(od.Product[x], x.ID, allOrder);
                }

                foreach (Product x in od.Product.Keys)
                {
                    var item = od.store.ItemInventory.Where(a => a.Key.ID == x.ID).FirstOrDefault();

                    _repo.MakeInventoryChanges(od.store.StoreID, x.ID, item.Value);
                }
                return(View(od));
            }
            catch
            {
                return(RedirectToAction("AddCustomer", "Customer"));
            }
        }