Beispiel #1
0
        public string Execute(IList <string> parameters, ISchoolSystemData data)
        {
            var studentId = int.Parse(parameters[0]);
            var student   = data.Students.GetById(studentId);

            return(student.ListMarks());
        }
Beispiel #2
0
        /* Could also extract Database provider for Teachers and Students collections
         * But it will become too complex for the purposes of this exam */
        public Engine(IReader readerProvider, IWriter writerProvider, IParser parserProvider, ISchoolSystemData schoolSystemData)
        {
            if (readerProvider == null)
            {
                throw new ArgumentNullException($"Reader {NullProvidersExceptionMessage}");
            }

            if (writerProvider == null)
            {
                throw new ArgumentNullException($"Writer {NullProvidersExceptionMessage}");
            }

            if (parserProvider == null)
            {
                throw new ArgumentNullException($"Parser {NullProvidersExceptionMessage}");
            }

            if (schoolSystemData == null)
            {
                throw new ArgumentNullException($"Data {NullProvidersExceptionMessage}");
            }

            this.reader           = readerProvider;
            this.writer           = writerProvider;
            this.parser           = parserProvider;
            this.schoolSystemData = schoolSystemData;
        }
Beispiel #3
0
 public CreateTeacherCommand(ITeacherFactory teacherFactory, ISchoolSystemData schoolSystemData, IMarkFactory markFactory)
 {
     this.teacherFactory   = teacherFactory ?? throw new ArgumentNullException("Teacher Factory cannot be null!");
     this.schoolSystemData = schoolSystemData ?? throw new ArgumentNullException("School system data cannot be null!");
     this.markFactory      = markFactory ?? throw new ArgumentNullException("Mark factory cannot be null!");
     this.currentTeacherId = 0;
 }
Beispiel #4
0
        public string Execute(IList <string> parameters, ISchoolSystemData data)
        {
            var teacherId = int.Parse(parameters[0]);

            data.Teachers.Remove(teacherId);
            return($"Teacher with ID {teacherId} was sucessfully removed.");
        }
        public string Execute(IList <string> parameters, ISchoolSystemData data)
        {
            var studentId = int.Parse(parameters[0]);

            data.Students.Remove(studentId);
            return($"Student with ID {studentId} was sucessfully removed.");
        }
Beispiel #6
0
        public string Execute(IList <string> parameters, ISchoolSystemData data)
        {
            var firstName = parameters[0];
            var lastName  = parameters[1];
            var grade     = (Grade)int.Parse(parameters[2]);

            var student   = this.studentFactory.CreateStudent(firstName, lastName, grade);
            var studentId = data.Students.Add(student);

            return($"A new student with name {firstName} {lastName}, grade {grade} and ID {studentId} was created.");
        }
        public string Execute(IList <string> parameters, ISchoolSystemData data)
        {
            var firstName = parameters[0];
            var lastName  = parameters[1];
            var subject   = (Subject)int.Parse(parameters[2]);

            var teacher   = this.teacherFactory.CreateTeacher(firstName, lastName, subject);
            var teacherId = data.Teachers.Add(teacher);

            return
                ($"A new teacher with name {firstName} {lastName}, subject {subject} and ID {teacherId} was created.");
        }
Beispiel #8
0
        public string Execute(IList <string> parameters, ISchoolSystemData schoolSystemData)
        {
            var studentId = int.Parse(parameters[0]);

            if (!this.studentData.Students.ContainsKey(studentId))
            {
                throw new ArgumentException("The given key was not present in the dictionary.");
            }

            this.studentData.Students.Remove(studentId);
            return($"Student with ID {studentId} was sucessfully removed.");
        }
Beispiel #9
0
        public string Execute(IList <string> parameters, ISchoolSystemData schoolSystemData)
        {
            var teacherId = int.Parse(parameters[0]);
            var studentId = int.Parse(parameters[1]);
            var mark      = float.Parse(parameters[2]);

            var student = this.studentData.Students.GetById(studentId);
            var teacher = this.teachersData.Teachers.GetById(teacherId);

            teacher.AddMark(student, mark);
            return($"Teacher {teacher.FirstName} {teacher.LastName} added mark {mark} to student {student.FirstName} {student.LastName} in {teacher.Subject}.");
        }
 public StudentListMarksCommand(ISchoolSystemData schoolSystemData)
 {
     this.schoolSystemData = schoolSystemData ?? throw new ArgumentNullException("School system data cannot be null!");
 }
 public TeacherAddMarkCommand(ISchoolSystemData schoolSystemData)
 {
     this.schoolSystemData = schoolSystemData ?? throw new ArgumentNullException("School system data cannot be null!");
 }
Beispiel #12
0
 public CreateStudentCommand(IStudentFactory studentFactory, ISchoolSystemData schoolSystemData)
 {
     this.schoolSystemData = schoolSystemData ?? throw new ArgumentNullException("School system data cannot be null!");
     this.studentFactory   = studentFactory ?? throw new ArgumentNullException("Student factory cannot be null!");
     this.currentStudentId = 0;
 }