Esempio n. 1
0
        // GET: Student
        /// <summary>
        /// Show the list of available courses
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            if (Session["userId"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            ViewBag.Email = Session["email"];
            ViewBag.Title = "Predmeti";

            int userId = (int)Session["userId"];
            List <StudentCourseViewModel> courseList = new List <StudentCourseViewModel>();

            var courseServices = new CourseServices(_courseRepository, _userRepository, _componentRepository);
            var courses        = courseServices.GetCoursesByUserId(userId);

            if (courses != null)
            {
                foreach (var course in courses)
                {
                    courseList.Add(new StudentCourseViewModel(course));
                }
            }

            return(View(courseList));
        }
Esempio n. 2
0
        public List <SimpleCourseModel> GetCoursesByStudentId(int studentId)
        {
            var courseServices = new CourseServices(_corRep, _usrRep, _comRep);
            var courses        = courseServices.GetCoursesByUserId(studentId);

            if (courses == null)
            {
                return(null);
            }
            else
            {
                var simpleCourseList = new List <SimpleCourseModel>();
                foreach (var course in courses)
                {
                    simpleCourseList.Add(new SimpleCourseModel(course));
                }

                return(simpleCourseList);
            }
        }