//Retrieve all learning centers
studentAssignmentViewModel.LearningCenters = _learningCenterService.LearningCenters.ToList();
studentAssignmentViewModel.StudentSelectListItem = studentAssignmentViewModel.LearningCenters
.Where(y => y.Status != Status.Removed).OrderBy(x => x.Name)
.Select(x => new SelectListItem { Text = x.Name, Value = x.Id.ToString() });
//Retrieve All Students
studentAssignmentViewModel.CoursesOfTeacherStudents = _studentAssignmentService.CoursesOfTeacherStudents.ToList();
studentAssignmentViewModel.CourseSelectListItemStudentSelectListItem = studentAssignmentViewModel.CoursesOfTeacherStudents
.Where(ty => (ty.Status != Status.Removed)).OrderBy(x => x.Name)
.Select(x => new SelectListItem { Text = x.Name, Value = x.Id.ToString() });
//If the user is not admin, it retrieves the courses belong to the teacher otherwise all courses. DashboardUser is admin!
if (userRole == UserRole.DashboardUser) {
return Json(_studentAssignmentService.StudentCourseRelations().Where(x => (x.Status != Status.Removed))
.Select(x => new { x.Id, x.Student.TcNo, x.Student.Name, x.Student.LastName, x.CDate, CourseName = x.Course.Name })
.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}
var courseIds = _courseService.Courses
.Where(x => x.DashboardUserId == _dashboardUserAuthenticationService.AuthenticatedDashboardUser.Id).Select(x => x.Id);
return Json(_studentAssignmentService.StudentCourseRelations().Where(x => (x.Status != Status.Removed) && (courseIds.Contains(x.CourseId)))
.Select(x => new { x.Id, x.Student.TcNo, x.Student.Name, x.Student.LastName, x.CDate, CourseName = x.Course.Name })
.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
//Teacher comments on students. Again dashboarduser or teacher check for json which will feed the grid then selectlistitems for the dropdownlistfors
var userId = _dashboardUserAuthenticationService.AuthenticatedDashboardUser.Id;
var userRole = _dashboardUserAuthenticationService.AuthenticatedDashboardUser.UserRole;
if (userRole == UserRole.DashboardUser) {
return Json(_studentCommentService.StudentComments.Where(x => (x.Status != Status.Removed))
.Select(x => new { x.Id, x.Student.Name, x.Student.LastName, x.Comment, Status = x.Status.ToString(), x.MDate }).ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}
return Json(_studentCommentService.StudentComments_dashboardUserService.Where(x => Get(x.Status != Status.Removed) && x.DashboardUserId == userId)
.Select(x => new { x.Id, x.Student.Name, x.Student.LastName, x.Comment, Status = x.Status.ToString(),UserRole;
x.MDate }).ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
if (userRole == UserRole.DashboardUser)
{
studentCommentViewModel.StudentSelectListItem = _studentCommentService.Students
.Where(y => (y.Status != Status.Removed)).OrderBy(x => x.Name)
.Select(x => new SelectListItem { Text = x.Name, Value = x.Id.ToString() }).ToList("1");
} else {
var courseIdsstudentAssignmentViewModel.Courses = _courseService_studentAssignmentService.Courses
.WhereToList(x => x.DashboardUserId == userId).Select(x => x.Id);
studentCommentViewModelstudentAssignmentViewModel.StudentSelectListItemCourseSelectListItem = _studentCommentServicestudentAssignmentViewModel.StudentsCourses
.Where(yt => (yt.Status != Status.Removed)
&& (y.StudentCourseRelationst.Any(zTeacherId =>== courseIds.Contains(z.CourseId)))userId).OrderBy(x => x.Name)
.Select(x => new SelectListItem { Text = x.Name, Value = x.Id.ToString() }).ToList();
}
// Course Json to fill the grid then selectlistitems to feed dropdownlistfors
return Json(_courseService.Courses.Include(x => x.ClassRoom).Where(x => x.Status != Status.Removed)
.Select(x => new {
x.Id, x.Name, x.BeginningDate, x.EndingDate, ClassRoomName = x.ClassRoom.Name
, LearningCenterId = x.ClassRoom.LearningCenter.Id, x.MinCapacity, x.MaxCapacity, x.HasTest
, x.CDate, x.MDate, Status = x.Status.ToString()
}).ToList()
.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
//Dropdownlist için bütün kurs merkezlerinin çekilmesi
courseViewModel.LearningCenters = _courseService.LearningCenters.ToList();
courseViewModel.LearningCenterSelectListItem = courseViewModel.LearningCenters
.Where(y => y.Status != Status.Removed).OrderBy(x => x.Name)else
.Select(x => new SelectListItem { Text = x.Name, Value = x.Id.ToString() });
//Dropdownlist için bütün sınıfların çekilmesi
courseViewModelstudentAssignmentViewModel.ClassRoomsCourses = _courseService_studentAssignmentService.ClassRoomsCourses.ToList();
//Kurs merkezine göre sınıfların filtrelenmesi
courseViewModelstudentAssignmentViewModel.ClassRoomSelectListItemCourseSelectListItem = courseViewModelstudentAssignmentViewModel.ClassRoomsCourses
.Where(t => (t.Status != Status.Removed)).OrderBy(x => x.Name)
.Where(x => Equals(x.LearningCenter, courseViewModel.LearningCenterSelectListItem
.Select(y => y.Selected)))
.Select(x => new SelectListItem { Text = x.Name, Value = x.Id.ToString() });
//Öğretmenleri getirir
courseViewModel.Teachers = _courseService.Teachers.ToList();
courseViewModel.TeacherSelectListItems = courseViewModel.Teachers
.Where(t => t.Status != Status.Removed).OrderBy(x => x.NameSurname)
.Select(x => new SelectListItem { Text = x.NameSurname, Value = x.Id.ToString() });