public IActionResult OnGet() { var usersId = HttpContext.Session.GetInt32("users_id"); if (usersId == null) { if (HttpContext.Request.Cookies.ContainsKey("users_id")) { usersId = int.Parse(HttpContext.Request.Cookies["users_id"]); var usersName = HttpContext.Request.Cookies["users_name"]; HttpContext.Session.SetInt32("users_id", (int)usersId); HttpContext.Session.SetString("users_name", usersName); } else { return(Redirect("SignIn")); } } var usersDao = new UsersDao(); Users = usersDao.GetById((int)usersId); Courses = usersDao.GetCourses((int)usersId); var purchaseDao = new PurchaseDao(); Purchases = purchaseDao.GetByUsersId((int)usersId); foreach (var purchase in Purchases) { purchase.CourseName = Courses.First(c => c.Id == purchase.CourseId).Name; } return(null); }