Exemplo n.º 1
0
        public Student GetStudentDetails(int studentId, int schoolYearId)
        {
            var student    = StudentStorage.GetById(studentId);
            var isEnrolled = ((DemoSchoolYearService)ServiceLocator.SchoolYearService).IsStudentEnrolled(studentId, schoolYearId);

            return(BuildStudentDetailsData(student, !isEnrolled));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        // 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"));
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        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));
        }
Exemplo n.º 7
0
        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));
        }
Exemplo n.º 8
0
 public ActionResult AddLecture(int id)
 {
     return(View(new SubjectAndStudentsViewModel(StudentStorage.Get(id))));
 }
Exemplo n.º 9
0
 public ActionResult Create(Student student)
 {
     StudentStorage.Add(student);
     return(RedirectToAction("Index"));
 }
Exemplo n.º 10
0
 // GET: Student
 public ActionResult Index()
 {
     return(View(StudentStorage.GetAll()));
 }
Exemplo n.º 11
0
 public void DeleteStudents(IList <Student> students)
 {
     StudentStorage.Delete(students);
 }
Exemplo n.º 12
0
 public void EditStudents(IList <Student> students)
 {
     StudentStorage.Update(students);
 }
Exemplo n.º 13
0
 public void AddStudents(IList <Student> students)
 {
     StudentStorage.Add(students);
 }
Exemplo n.º 14
0
 public StudentsController(StudentStorage studentStorage)
 {
     _studentStorage = studentStorage;
 }