コード例 #1
0
        public async Task <IActionResult> PassengerIndex(string Location, string Destination)
        {
            if (HttpContext.Session.GetInt32("UserId") == null || HttpContext.Session.GetInt32("UserId") == 0)
            {
                TempData["Message"] = "You must be logged in to access that page";
                return(RedirectToAction("SignIn", "User"));
            }

            ViewBag.UserId      = HttpContext.Session.GetInt32("UserId");
            TempData["Message"] = null;

            List <Post> availableDrivers = await _postLogic.GetAvailableDrivers(Location, Destination);

            HttpContext.Session.SetString("Location", Location);
            HttpContext.Session.SetString("Destination", Destination);

            if (availableDrivers.Count < 1)
            {
                TempData["Message"] = "There are no available drivers at this time";
            }

            return(View(availableDrivers));
        }