public IActionResult Index()
        {
            var customer = _repo.ReadInCustomer().ToList();
            var ord      = _ord.ReadInOrder().ToList();

            List <CustomerViewModel> cvm = new List <CustomerViewModel>();

            foreach (var cus in customer)
            {
                foreach (var o in ord)
                {
                    if (FullOrder.storeID == o.StoreId && cus.Id == o.CustId)
                    {
                        CustomerViewModel cx = new CustomerViewModel();
                        cx.Id       = cus.Id;
                        cx.Fname    = cus.Fname;
                        cx.Lname    = cus.Lname;
                        cx.Email    = cus.Email;
                        cx.Phone    = cus.Phone;
                        cx.UserPass = cus.UserPass;
                        cvm.Add(cx);
                    }
                }
            }
            return(View(cvm));
        }
        // GET: /<controller>/
        public IActionResult Index()
        {
            var order = _repo.ReadInOrder().OrderByDescending(e => e.OrderDate).ToList();

            List <OrderViewModel> ovm = new List <OrderViewModel>();

            foreach (var ord in order)
            {
                if (ord.StoreId == FullOrder.storeID)
                {
                    OrderViewModel ox = new OrderViewModel();
                    ox.OrderId   = ord.OrderId;
                    ox.CustId    = ord.CustId;
                    ox.OrderDate = ord.OrderDate;
                    ox.Price     = ord.Price;
                    ox.StoreId   = ord.StoreId;
                    ovm.Add(ox);
                }
            }
            return(View(ovm));
        }
        public ActionResult LoggedIn(LoginViewModel collection)
        {
            var v    = _repo.ReadInCustomer().FirstOrDefault(e => e.Email.Equals(collection.Email) && e.UserPass.Equals(collection.Password));
            var o    = _order.ReadInOrder().OrderByDescending(e => e.OrderDate); // Super imprtant to convert to list to close connection
            var stor = _store.ReadInStore().ToList();                            // ned to close connection by first creating a list

            if (v != null && o != null)
            {
                CustomerInfo.Fname = v.Fname;
                CustomerInfo.Id    = v.Id;
                CustomerInfo.Lname = v.Lname;
                CustomerInfo.email = v.Email;

                FullOrder.userName = v.Fname;
                FullOrder.UserID   = v.Id;

                //List<StoreViewModel> svm = new List<StoreViewModel>();
                // RedirectToAction("Action", "Controller");
                StoreOfSpecificCustomerModel _Main = new StoreOfSpecificCustomerModel
                {
                    CVM = new CustomerViewModel(),
                    LOS = new List <StoreViewModel>()
                };
                _Main.CVM.Email = v.Email;
                _Main.CVM.Fname = v.Fname;
                _Main.CVM.Id    = v.Id;
                _Main.CVM.Lname = v.Lname;
                DateTime dt   = DateTime.Now;
                double   time = 25;
                double   date = 25;
                //For each order go through and check if store id and customer id match
                foreach (var _stor in stor)
                {
                    foreach (var ord in o)
                    {
                        if (v.Id == ord.CustId && ord.StoreId == _stor.Id)
                        {
                            TimeSpan ts2 = (TimeSpan)(dt - ord.OrderDate);
                            date = ts2.TotalMinutes / 60;
                            if (date < time)
                            {
                                time = date;
                            }
                        }
                    }
                    StoreViewModel stm = new StoreViewModel();
                    stm.Id            = _stor.Id;
                    stm.StoreLocation = _stor.StoreLocation;
                    stm.StoreName     = _stor.StoreName;
                    if (v.Lname.Equals("admin"))
                    {
                        stm.date = 25;
                    }
                    else
                    {
                        stm.date = time;
                    }
                    time = 25;
                    _Main.LOS.Add(stm);
                }
                return(View(_Main));
            }
            if (CustomerInfo.Lname.Equals("admin"))
            {
                return(RedirectToAction("Index", "Login"));
            }
            else
            {
                return(RedirectToAction("MyOrder", "login"));
            }
        }