// GET: StudentCourse public ActionResult Index(StudentCourseViewModel model) { ViewBag.Title = "Cursos"; ViewBag.SelectedMenu = EnumStudentMenu.Cursos; model.userName = User.Identity.Name; model.idSearchDepartment = model.idSearchDepartment; model.CourseName = (string.IsNullOrEmpty(model.CourseName)) ? "" : model.CourseName; var cursos = _studentservice.getStudentCourses(model); return View(cursos); }
public StudentCourseViewModel getStudentCourses(StudentCourseViewModel model) { var courses = new StudentCourseViewModel(); var cursos = _enrollRepository.Get().ToList() .Where(m => (m.Estudiante.Email == model.userName) && (m.Curso.Descripcion.Contains(model.CourseName)) && ((model.idSearchDepartment == 0) || m.Curso.EspecialidadId == model.idSearchDepartment) ) .ToList(); courses.userName = model.userName; courses.idSearchDepartment = model.idSearchDepartment; _departmentRepository.Get().ToList().ForEach(d => courses.SearchDepartment.Add(new SelectListItem { Text = d.Descripcion, Value = d.Id.ToString() })); courses.SearchDepartment.Add(new SelectListItem { Text = "-- Todos --", Value = "0" }); cursos.ForEach(c => courses.CourseDetails.Add(new CourseModel(c))); return courses; }