Пример #1
0
        /// <returns>Returns passed courses of student.</returns>
        public ActionResult PassedCourses()
        {
            Domain.Core.Student user = _studentRepository.GetWithCourses(User.Identity.Name);
            if (user != null)
            {
                var courses       = new List <PassedCourse>();
                var passedCourses = user.Courses
                                    .Where(c => c.StartDate.AddDays(c.Duration).CompareTo(DateTime.Now) <= 0).ToList();
                if (passedCourses.Count != 0)
                {
                    foreach (var course in passedCourses)
                    {
                        var mark = _registerRepository.GetMarkOfStudent(course.CourseId, user.UserName);
                        courses.Add(new PassedCourse
                        {
                            CourseId  = course.CourseId,
                            Duration  = course.Duration,
                            Mark      = (mark == 0) ? null : (int?)mark,
                            StartDate = course.StartDate,
                            Theme     = course.Theme,
                            Title     = course.Title,
                            Lecturer  = _courseRepository.GetWithLecturer(course.CourseId).Lecturer
                        });
                    }

                    return(PartialView(courses));
                }
            }

            return(new ContentResult {
                Content = "<p>There are no such courses.</p>"
            });
        }