public ActionResult GradeList(BaseViewModel model) { GradeListViewModel modelOut = new GradeListViewModel(); if (model.RealisationsID.HasValue) { modelOut.GradeItems = storage.GetGradeList(model.RealisationsID.Value, storage.GetStudentID(User.Identity.Name)); } else { return(RedirectToAction("Index")); } return(View(modelOut)); }
// GET: Grade public ActionResult Index(Guid?enrollmentId) { if (!UserIsInRole("Student")) { return(RedirectToAction("Index", "Home")); } Enrollment enrollment; if (enrollmentId == null) { enrollment = _enrollmentQuery.Handle(new EnrollmentInputGetByStudent { StudentId = Authentication.UserId }).Enrollment; } else { enrollment = _enrollmentQuery.Handle(new EnrollmentInputGet { EnrollmentId = (Guid)enrollmentId }).Enrollment; } var disciplines = _disciplineQuery.Handle(new DisciplineInputListByEnrollment { EnrollmentId = enrollment.Id, StudentId = Authentication.UserId, SemesterBegin = enrollment.Begin, SemesterEnd = enrollment.End }).Disciplines; var grades = new GradeListViewModel() { EnrollmentId = (Guid)enrollment.Id }; grades.Students = disciplines.Select(x => new GradeListItem { Grade = x.Activities.Sum(y => y.Grade), FinalExam = x.FinalExamGrade, Discipline = x.Name, DisciplineId = x.Id, Status = DictionaryStudentStatus.Get(x.StudentStatus, out string color), StatusColor = color });
public ActionResult ParentPage(int?parent) { if (!isAuthenticate()) { return(Redirect("/Admin/LoginPage/?error")); } if (!IsAdmin()) { if (!IsParent()) { return(Redirect("/Admin/LoginPage/?noPermission")); } } IQueryable <Grade> grades = db.Grades.Include(s => s.Student).Include(s => s.Lesson.Course).Include(s => s.Lesson.Group); IQueryable <Student> students1 = db.Students.Include(s => s.Parent); if (parent != null && parent != 0) { if (IsAdmin()) { Student student = students1.First(s => s.ParentId == parent); grades = grades.Where(s => s.StudentId == student.Id); } else { return(Redirect("/Admin/LoginPage/?noPermission")); } } else { IQueryable <Parent> parents1 = db.Parents; Parent parent1 = null; string email = (string)Session["currentUser"]; foreach (Parent p in parents1) { if (p.Login == email) { parent1 = p; break; } } if (parent1 != null) { Student student = students1.First(s => s.ParentId == parent1.Id); grades = grades.Where(s => s.Student.ParentId == parent1.Id); //grades = grades.Where(s => s.StudentId == student.Id); } } List <Parent> parents = db.Parents.ToList(); // устанавливаем начальный элемент, который позволит выбрать всех parents.Insert(0, new Parent { Name = "Все", Id = 0 }); GradeListViewModel plvm = new GradeListViewModel { Grades = grades.Include(s => s.Student).Include(s => s.Lesson.Course).Include(s => s.Lesson.Group).ToList(), Parents = new SelectList(parents, "Id", "Name") }; return(View(plvm)); }
public ActionResult StudentPage(int?student) { if (!isAuthenticate()) { return(Redirect("/Admin/LoginPage/?error")); } if (!IsParent()) { IQueryable <Lesson> lessons = db.Lessons.Include(s => s.Group).Include(s => s.Course); IQueryable <Grade> grades = db.Grades.Include(s => s.Student).Include(s => s.Lesson.Course).Include(s => s.Lesson.Group); if (student != null && student != 0) { if (!IsStudent()) { if (!IsParent()) { grades = grades.Where(s => s.StudentId == student); } else { return(Redirect("/Admin/LoginPage/?noPermission")); } } else { return(Redirect("/Admin/LoginPage/?noPermission")); } } else { IQueryable <Student> students0 = db.Students; Student student1 = null; string email = (string)Session["currentUser"]; foreach (Student s in students0) { if (s.Login == email) { student1 = s; break; } } if (student1 != null) { grades = grades.Where(s => s.StudentId == student1.Id); } } List <Student> students = db.Students.ToList(); // устанавливаем начальный элемент, который позволит выбрать всех students.Insert(0, new Student { Name = "Все", Id = 0 }); GradeListViewModel plvm = new GradeListViewModel { Grades = grades.ToList(), Students = new SelectList(students, "Id", "Name") }; return(View(plvm)); } else { return(Redirect("/Admin/LoginPage/?noPermission")); } }
public ActionResult SchoolKidPage(int?schoolKid) { if (!isAuthenticate()) { return(Redirect("/Admin/LoginPage/?error")); } if (!IsParent()) { IQueryable <Grade> grades = db.Grades.Include(s => s.SchoolKid).Include(s => s.Subject); if (schoolKid != null && schoolKid != 0) { if (!IsSchoolKid()) { if (!IsParent()) { grades = grades.Where(s => s.SchoolKidId == schoolKid); } else { return(Redirect("/Admin/LoginPage/?noPermission")); } } else { return(Redirect("/Admin/LoginPage/?noPermission")); } } else { IQueryable <SchoolKid> schoolKids0 = db.SchoolKids; SchoolKid schoolKid1 = null; string email = (string)Session["currentUser"]; foreach (SchoolKid s in schoolKids0) { if (s.Login == email) { schoolKid1 = s; break; } } if (schoolKid1 != null) { grades = grades.Where(s => s.SchoolKidId == schoolKid1.Id); } } List <SchoolKid> schoolKids = db.SchoolKids.ToList(); // устанавливаем начальный элемент, который позволит выбрать всех schoolKids.Insert(0, new SchoolKid { Name = "Все", Id = 0 }); GradeListViewModel plvm = new GradeListViewModel { Grades = grades.ToList(), SchoolKids = new SelectList(schoolKids, "Id", "Name") }; return(View(plvm)); } else { return(Redirect("/Admin/LoginPage/?noPermission")); } }