public void OnGet(string courseId) { var id = int.Parse(courseId); var courseDao = new CourseDao(); Course = courseDao.GetById(id); var commentDao = new CommentDao(); Comments = commentDao.GetByCourseId(id); var usersId = HttpContext.Session.GetInt32("users_id"); if (usersId == null && 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); } UserIsAuthorized = usersId != null; if (UserIsAuthorized) { var usersCourses = new UsersDao().GetCourses((int)usersId); UserHasThisCourse = usersCourses.Select(c => c.Id).Contains(id); } }