public ActionResult Login(string email, string password)
        {
            if (Utl.IsLoggedIn(Session))
            {
                return(RedirectToAction("Index", "Home"));
            }

            Account account = db.Accounts.FirstOrDefault(a => a.Email == email && a.Password == password);

            if (account == null)
            {
                return(View(new List <string> {
                    "The email and password you entered are incorrect. Please try again."
                }));
            }

            var accountOrders = db.Orders.Include(o => o.Product).Include(o => o.Account)
                                .Where(a => a.AccountID == account.AccountID).ToList();


            Session["accountID"] = account.AccountID;
            Session["cart"]      = Utl.CreateCart(Session, accountOrders);
            Session.Timeout      = 60;

            return(RedirectToAction("Index", "Home"));
        }
        public ActionResult AddItem(int accountID, int productID, int amount)
        {
            if (!isAbleToChangeOrder(accountID))
            {
                return(RedirectToAction("Index", "Home"));
            }

            var accountOrders = getAccountsOrders(accountID);

            addItemToDB(accountID, productID, amount, accountOrders);

            db.SaveChanges();
            Session["cart"] = Utl.CreateCart(Session, accountOrders.ToList());

            return(RedirectToAction("Index", "Home"));
        }
        public ActionResult UpdateItem(int accountID, int productID, int amount)
        {
            if (!isAbleToChangeOrder(accountID))
            {
                return(RedirectToAction("Index", "Home"));
            }

            var accountOrders = getAccountsOrders(accountID);

            if (accountOrders.Any(o => o.ProductID == productID))
            {
                updateItemInDB(accountID, productID, amount);
            }
            else
            {
                addNewItemToDB(accountID, productID, amount);
            }

            db.SaveChanges();
            Session["cart"] = Utl.CreateCart(Session, accountOrders.ToList());

            return(RedirectToAction("Index", "Home"));
        }