public Student GetStudentDetails(int studentId, int schoolYearId) { var student = StudentStorage.GetById(studentId); var isEnrolled = ((DemoSchoolYearService)ServiceLocator.SchoolYearService).IsStudentEnrolled(studentId, schoolYearId); return(BuildStudentDetailsData(student, !isEnrolled)); }
public Student GetById(int id, int schoolYearId) { var student = StudentStorage.GetById(id); var isEnrolled = ServiceLocator.SchoolYearService.GetStudentAssignments().Any(x => x.StudentRef == id && x.SchoolYearRef == schoolYearId && x.IsEnrolled); return(BuildStudentDetailsData(student, !isEnrolled)); }
public IList <Student> GetClassStudents(int classId, int?markingPeriodId, bool?isEnrolled = null) { var students = StudentStorage.GetAll(); var stWithDrawDictionary = ServiceLocator.ClassService.GetClassPersons(null, classId, isEnrolled, markingPeriodId) .GroupBy(x => x.PersonRef).ToDictionary(x => x.Key, x => !x.First().IsEnrolled); students = students.Where(s => stWithDrawDictionary.ContainsKey(s.Id)).ToList(); return(PrepareStudentListDetailsData(students, stWithDrawDictionary)); }
// POST: api/Student public IHttpActionResult Post([FromBody] Student value) { bool isValid = ModelState.IsValid; if (StudentStorage.AddStudentToList(value)) { return(Created("Added successfully", value)); } return(BadRequest("Please enter a student with a valid grade")); }
public ActionResult Details(int id) { Student student = StudentStorage.Get(id); student.Subjects = new List <Subject> { new Subject { Name = "Temp F*g", Description = "det gode f*g" } }; return(View(student)); }
public IList <Student> GetTeacherStudents(int teacherId, int schoolYearId) { var students = StudentStorage.GetAll(); var markingPeriods = ServiceLocator.MarkingPeriodService.GetMarkingPeriods(schoolYearId); var classPersons = ((DemoClassService)ServiceLocator.ClassService).GetClassPersonsByMarkingPeriods(markingPeriods); students = students.Where(s => classPersons.Any(cp => cp.PersonRef == s.Id)).ToList(); var stWithDrawDic = ((DemoSchoolYearService)ServiceLocator.SchoolYearService).GetStudentAssignments(schoolYearId, null) .GroupBy(x => x.StudentRef).ToDictionary(x => x.Key, x => !x.First().IsEnrolled); return(PrepareStudentListDetailsData(students, stWithDrawDic)); }
public PaginatedList <Student> SearchStudents(int schoolYearId, int?classId, int?teacherId, int?classmatesToId, string filter, bool orderByFirstName, int start, int count, int?markingPeriod, bool enrolledOnly) { var students = StudentStorage.GetAll().AsEnumerable(); if (!string.IsNullOrEmpty(filter)) { var words = filter.ToLowerInvariant().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); students = students.Where(s => words.Any(w => s.FirstName.ToLower().Contains(w) || s.LastName.ToLower().Contains(w))); } var classTeachers = ServiceLocator.ClassService.GetClassTeachers(classId, teacherId); var markingPeriods = ServiceLocator.MarkingPeriodService.GetMarkingPeriods(schoolYearId); var stSchoolYears = ((DemoSchoolYearService)ServiceLocator.SchoolYearService).GetStudentAssignments(schoolYearId, null); var classPersons = ((DemoClassService)ServiceLocator.ClassService).GetClassPersons(classId); classPersons = classPersons.Where(x => classTeachers.Any(y => y.ClassRef == x.ClassRef)).ToList(); classPersons = classPersons.Where(x => markingPeriods.Any(y => y.Id == x.MarkingPeriodRef)).ToList(); students = students.Where(x => classPersons.Any(y => y.PersonRef == x.Id)); students = students.Where(x => stSchoolYears.Any(y => y.StudentRef == x.Id)); students = orderByFirstName ? students.OrderBy(s => s.FirstName) : students.OrderBy(s => s.LastName); var res = students.ToList(); IDictionary <int, bool> stWithDrawDic = new Dictionary <int, bool>(); foreach (var student in res) { var isEnrolled = stSchoolYears.Any(x => x.StudentRef == student.Id && x.IsEnrolled) && classPersons.Any(x => x.PersonRef == student.Id && x.IsEnrolled); if (!stWithDrawDic.ContainsKey(student.Id)) { stWithDrawDic.Add(student.Id, !isEnrolled); } else { stWithDrawDic[student.Id] = !isEnrolled; } } return(new PaginatedList <Student>(PrepareStudentListDetailsData(res, stWithDrawDic), start / count, count)); }
public ActionResult AddLecture(int id) { return(View(new SubjectAndStudentsViewModel(StudentStorage.Get(id)))); }
public ActionResult Create(Student student) { StudentStorage.Add(student); return(RedirectToAction("Index")); }
// GET: Student public ActionResult Index() { return(View(StudentStorage.GetAll())); }
public void DeleteStudents(IList <Student> students) { StudentStorage.Delete(students); }
public void EditStudents(IList <Student> students) { StudentStorage.Update(students); }
public void AddStudents(IList <Student> students) { StudentStorage.Add(students); }
public StudentsController(StudentStorage studentStorage) { _studentStorage = studentStorage; }