//[ValidateAntiForgeryToken]
        //POST:Restaurant/ShowUsersOrders
        public IActionResult ShowUsersOrders()
        {
            //List<Models.Ingredients> ingredientlist = new List<Models.Ingredients>();

            var pizzas = db2.getPizzas();
            var orders = db2.getOrders();

            foreach (var order in orders)
            {
                Models.Orderpizza y = new Models.Orderpizza();
                y.locationfid_op   = order.locationfid_op;
                y.orderid          = order.orderid;
                y.userFID          = order.userFID;
                y.Timecheck        = order.Timecheck;
                y.Timecheckdefault = order.Timecheckdefault;
                if (y.locationfid_op == Int32.Parse(TempData["id"].ToString()))
                {
                    TempData.Keep("id");
                    orderlist.Add(y);
                }
            }
            foreach (var pizza in pizzas)
            {
                //foreach (var order in orderlist) {
                //show pizza ruined from mismatch of indiv pizza in domain/webapp
                //alternative show.
                Models.Indiv_pizza x = new Models.Indiv_pizza();
                x.pizzaId         = pizza.pizzaId;
                x.crustFID        = pizza.crustFID.ToString();
                x.sizeFID         = pizza.sizeFID.ToString();
                x.crustId         = pizza.crustFID.GetValueOrDefault();
                x.crust1          = db2.getCrustById(pizza.crustFID).crust1;
                x.totalcost_crust = pizza.totalcost;
                x.sizeId          = pizza.sizeFID.GetValueOrDefault();
                x.size1           = db2.getSizeById(pizza.sizeFID).size1;
                x.totalcost_size  = pizza.totalcost;
                x.Ingredient0FID  = pizza.Ingredient0FID.ToString();
                x.Ingredient1FID  = pizza.Ingredient1FID.ToString();
                x.Ingredient2FID  = pizza.Ingredient2FID.ToString();
                x.Ingredient3FID  = pizza.Ingredient3FID.ToString();
                x.Ingredient4FID  = pizza.Ingredient4FID.ToString();
                x.count           = pizza.count;
                x.orderFID        = pizza.orderFID;
                x.totalcost       = pizza.totalcost;

                if (db2.getNextOrderId() == x.orderFID.GetValueOrDefault())
                {
                    pizzalist.Add(x);
                }
                //}
            }

            return(View(pizzalist));
        }
        public IActionResult Pizzabuilder(Models.Indiv_pizza ip, int?id)
        {
            Domain.Indiv_pizza dmc = new Domain.Indiv_pizza();

            dmc.count          = ip.count;
            dmc.crustFID       = db2.CrustStringToID(ip.crustFID);
            dmc.Ingredient0FID = db2.IngredientStringToId(ip.Ingredient0FID);
            dmc.Ingredient1FID = db2.IngredientStringToId(ip.Ingredient1FID);
            dmc.Ingredient2FID = db2.IngredientStringToId(ip.Ingredient2FID);
            dmc.Ingredient3FID = db2.IngredientStringToId(ip.Ingredient3FID);
            dmc.Ingredient4FID = db2.IngredientStringToId(ip.Ingredient4FID);
            //need to set orderid to +1 of largest order id... not the proper way since it has a
            dmc.orderFID = db2.getNextOrderId();
            if (id != null)
            {
                TempData["id"] = id;
            }
            dmc.pizzaId = ip.pizzaId;
            dmc.sizeFID = db2.SizeStringToID(ip.sizeFID);
            //get price from stringid -> id -> db -> price
            dmc.totalcost = (db2.getIngredientsById(db2.IngredientStringToId(ip.Ingredient0FID)).cost_ing +
                             db2.getIngredientsById(db2.IngredientStringToId(ip.Ingredient1FID)).cost_ing +
                             db2.getIngredientsById(db2.IngredientStringToId(ip.Ingredient2FID)).cost_ing +
                             db2.getIngredientsById(db2.IngredientStringToId(ip.Ingredient3FID)).cost_ing +
                             db2.getIngredientsById(db2.IngredientStringToId(ip.Ingredient4FID)).cost_ing +
                             db2.getCrustById(db2.CrustStringToID(ip.crustFID)).totalcost_crust +
                             db2.getSizeById(db2.SizeStringToID(ip.sizeFID)).totalcost_size) * ip.count;
            TempData.Keep("id");
            if (dmc.totalcost > 5000 || ip.count > 100)
            {
                //ought to have message saying cost is over 5000.
                return(View());
            }
            IEnumerable <Inventory> inv = db2.getInventory();

            foreach (var i in inv)
            {
                if (i.resfId == Int32.Parse(TempData["id"].ToString()) && ((i.FkIngredient == dmc.Ingredient0FID && dmc.Ingredient0FID != 14) || (i.FkIngredient == dmc.Ingredient1FID && dmc.Ingredient1FID != 14) || (i.FkIngredient == dmc.Ingredient2FID && dmc.Ingredient2FID != 14) || (i.FkIngredient == dmc.Ingredient3FID && dmc.Ingredient3FID != 14) || (i.FkIngredient == dmc.Ingredient4FID && dmc.Ingredient4FID != 14)))
                {
                    i.stock = i.stock - ip.count;
                    db2.UpdateStock(i);
                    TempData.Keep("id");
                }
            }
            //TempData.Keep();



            //still need to update stock ... this will be done on db.save()
            //still need to update order ... this will have its own view
            try
            {
                db2.AddPizza(dmc);
                db2.Save();
                return(RedirectToAction("OrderPizza"));
            }
            catch
            {
                return(View());
            }
        }