Пример #1
0
        public async Task <IActionResult> Index(string schoolId)
        {
            if (string.IsNullOrEmpty(schoolId))
            {
                IEnumerable <School> schools = await SchoolFromContext();

                if (schools.Count() > 1)
                {
                    return(RedirectToAction(nameof(SelectSchool), new { redirectValue = "Index" }));
                }
                if (schools.Count() == 0)
                {
                    return(RedirectToAction("Index", "Home"));
                }
                schoolId = schools.FirstOrDefault().Id;
            }
            CheckSchool checkSchool = new CheckSchool(_schoolService, HttpContext.Session);

            if (!checkSchool.IsSchoolAllowed(schoolId))
            {
                return(RedirectToAction(Common.UsersConstants.redirectPayPageAction, Common.UsersConstants.redirectPayPageController, new { schoolId }));
            }
            ViewBag.schoolId = schoolId;
            IEnumerable <Course> teacherCourses = _courseService.GetTeacherCourses(
                HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier), schoolId, true);

            if (teacherCourses != null &&
                teacherCourses.Where(cour => cour.AllowOneTimePrice == true).Count() > 0)
            {
                ViewBag.hasOneTimeCourses = true;
            }
            return(View());
        }
        public IActionResult SchoolDetails(string id, bool isItAdmin)
        {
            if (string.IsNullOrEmpty(id))
            {
                if (isItAdmin)
                {
                    return(RedirectToAction("Index", "School"));
                }
                else
                {
                    return(RedirectToAction(nameof(Index), new { redirect = "SchoolDetails" }));
                }
            }
            School school = _schoolService.GetSchool(id);

            if (school == null)
            {
                return(NotFound());
            }
            CheckSchool checkSchool = new CheckSchool(_schoolService, HttpContext.Session);

            if (!isItAdmin && !checkSchool.IsSchoolAllowed(id))
            {
                return(RedirectToAction(Common.UsersConstants.redirectPayPageAction, Common.UsersConstants.redirectPayPageController, new { schoolId = id }));
            }
            if (!isItAdmin && !school.Enable)
            {
                return(NotFound());
            }
            ViewBag.isItAdmin = isItAdmin;
            return(View(school));
        }
Пример #3
0
        public async Task <IActionResult> TeacherCourses(string schoolId)
        {
            if (string.IsNullOrEmpty(schoolId))
            {
                IEnumerable <School> schools = await SchoolFromContext();

                if (schools.Count() > 1)
                {
                    return(RedirectToAction(nameof(SelectSchool), new { redirectValue = "TeacherCourses" }));
                }
                else if (schools.Count() == 1)
                {
                    schoolId = schools.FirstOrDefault().Id;
                }
                else
                {
                    return(View(new List <Course>()));
                }
            }
            CheckSchool checkSchool = new CheckSchool(_schoolService, HttpContext.Session);

            if (!checkSchool.IsSchoolAllowed(schoolId))
            {
                return(RedirectToAction(Common.UsersConstants.redirectPayPageAction, Common.UsersConstants.redirectPayPageController, new { schoolId }));
            }
            ViewBag.schoolId = schoolId;
            IEnumerable <Course> courses = _courseService.GetTeacherCourses(
                HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier), schoolId, false);

            return(View(courses));
        }
        public IActionResult SchoolCalculation(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(RedirectToAction(nameof(Index), new { redirect = "SchoolCalculation" }));
            }
            CheckSchool checkSchool = new CheckSchool(_schoolService, HttpContext.Session);

            if (!checkSchool.IsSchoolAllowed(id))
            {
                return(RedirectToAction(Common.UsersConstants.redirectPayPageAction, Common.UsersConstants.redirectPayPageController, new { schoolId = id }));
            }
            SchoolCalculationsViewModel model = _schoolService.GetSchoolDetail(id, "", DateTime.Now, "", "");

            if (model == null)
            {
                return(RedirectToAction(nameof(Index), new { redirect = "SchoolCalculation" }));
            }
            return(View(model));
        }