コード例 #1
0
        // GET: Location
        public ActionResult Index(LocationWeb locationweb)
        {
            int herndoninventoryfromdb = Repo.getHerndonInventory();
            int restoninventoryfromdb  = Repo.getRestonInventory();

            if (herndoninventoryfromdb == 20)
            {
                ModelState.AddModelError("", "yay herndonis20!!!");
            }


            return(View(locationweb));
        }
コード例 #2
0
 public ActionResult ByLocation(LocationWeb location)
 {
     try
     {
         var libLocaton    = MapperWeb.Map(location);
         var checkLocation = Repo.GetLocationIdByName(location.Address);
         if (checkLocation > 0)
         {
             return(RedirectToAction("SearchResultsLocation", "OrderHistory", new { searchID = checkLocation, searchOption = location.SearchOption })); //add search option
         }
         else
         {
             ModelState.AddModelError(string.Empty, "Location doesn't exist. Please edit your search");
             return(View());
         }
         // TODO: Add insert logic
     }
     catch
     {
         return(View());
     }
 }
コード例 #3
0
        public ActionResult ByLocation()
        {
            LocationWeb location = new LocationWeb();

            return(View(location));
        }
コード例 #4
0
        public ActionResult Index(OrderWeb ordertoplace)
        {
            int herndoninventoryfromdb = Repo.getHerndonInventory();
            int restoninventoryfromdb  = Repo.getRestonInventory();

            int userID = (int)TempData["CurrentUserID"];

            UserWeb     currentuser = new UserWeb();
            LocationWeb location    = new LocationWeb();

            //List<MainLibrary.Models.Order> allOrders = Repo.GetOrders().Reverse().ToList();

            //foreach (MainLibrary.Models.Order order in allOrders)

            //{
            //    if(order.User.UserID == userID)
            //    {
            //        TimeSpan diff = DateTime.Now - order.TimeOfOrder;

            //        if (diff.TotalHours > 2)
            //        {
            //            ModelState.AddModelError("", "You ordered less than two hours ago!!!!");
            //            TempData["CurrentUserID"] = userID;
            //            break;

            //        }
            //    }

            //}



            string userStore = Repo.getUserStore(userID);

            location.StoreName = userStore;

            if (userStore == "Reston")
            {
                location.LocID       = 2;
                location.StoredPizza = Repo.getRestonInventory();
            }
            else if (userStore == "Herndon")
            {
                location.StoredPizza = Repo.getHerndonInventory();
                location.LocID       = 1;
            }

            string firstName = Repo.getFirstName(userID);
            string lastName  = Repo.getLastName(userID);

            currentuser.setUser(firstName, lastName, userStore, userID);


            ordertoplace.Location = location;
            ordertoplace.User     = currentuser;


            if (Decimal.Compare(ordertoplace.CalcOrderPrice(), 500.0m) > 0)
            {
                ModelState.AddModelError("", "That is more than $500!!!!");
                TempData["CurrentUserID"] = userID;
                return(View(ordertoplace));
            }

            if (userStore == "Herndon")
            {
                if ((herndoninventoryfromdb - ordertoplace.amountDough()) < 0)
                {
                    ModelState.AddModelError("", "Not enough inventory left from Herndon please order less!!!!");
                    TempData["CurrentUserID"] = userID;
                }
                else
                {
                    Repo.AddOrder(Mapper.Map(ordertoplace));
                    Repo.SaveChanges();
                    Repo.removeFromHerndonInv(ordertoplace.amountDough());
                    Repo.SaveChanges();
                    return(RedirectToAction("Index", ""));
                }
            }

            else if (userStore == "Reston")
            {
                if ((restoninventoryfromdb - ordertoplace.amountDough()) < 0)
                {
                    ModelState.AddModelError("", "Not enough inventory left from Reston please order less!!!!");
                    TempData["CurrentUserID"] = userID;
                }
                else
                {
                    int doughtosubtract = ordertoplace.amountDough();
                    Repo.AddOrder(Mapper.Map(ordertoplace));
                    Repo.SaveChanges();
                    Repo.removeFromRestonInv(doughtosubtract);
                    Repo.SaveChanges();
                    return(RedirectToAction("Index", ""));
                }
            }



            return(View(ordertoplace));
        }