コード例 #1
0
        public async Task <IActionResult> DriverIndex(int?DriverId)
        {
            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"));
            }

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

            List <Ride> driverHistory = await _rideLogic.GetDriverRides(DriverId);

            HttpContext.Session.SetInt32("DriverId", Convert.ToInt32(DriverId));

            if (driverHistory.Count == 0)
            {
                TempData["Message"] = "You have no rides";
            }

            return(View(driverHistory));
        }