Esempio n. 1
0
        // First action called when application runs
        public ActionResult Index()
        {
            // create variable to keep track of the user ID
            int userId;

            // check to see if the user id is stored in session
            if (Session["UserId"] != null)
            {
                // assign logged in users id to variable
                userId = Convert.ToInt32(Session["UserId"]);
            }

            // check to see if the users cityId is stored as a cookie
            if (Request.Cookies["cityId"] != null)
            {
                // if so get the cookie and send the user to homescreen for that city
                int cityId = Convert.ToInt32(Request.Cookies["cityId"].Value);
                HomeIndexViewModel model = new HomeIndexViewModel(cityId);
                return View("Index", model);
            }
            else
            {
                // send the user to locator page to select their current city
                LocatorViewModel model = new LocatorViewModel();
                return View("Locator", model);
            }
        }
 // called when a user clicks a subcategory id to view listings
 public ActionResult Index(int subcategoryId)
 {
     // check to make sure city id cookie is populated
     if (Request.Cookies["cityId"] != null)
     {
         // return the view listings with the city and subcategory id
         int cityId = Convert.ToInt32(Request.Cookies["cityId"].Value);
         ViewListingsViewModel model = new ViewListingsViewModel(cityId, subcategoryId);
         return View("ViewListings", model);
     }
     else
     {
         // there is no selected city id so send user to locator to chose a city
         LocatorViewModel locatorModel = new LocatorViewModel();
         Response.Redirect("/Home/Locator");
         return View();
     }
 }
Esempio n. 3
0
 // sends the user to the locator page to select their city
 public ActionResult Locator()
 {
     LocatorViewModel model = new LocatorViewModel();
     return View("Locator", model);
 }