Example #1
0
        public void GetSubjects(string scope, string auth)
        {
            try
            {
                switch (scope)
                {
                case "ALL":
                    Object(SubjectSrv.GetAllSubjects());
                    break;

                case "MINE":
                    Object(StudentSrv.GetSubjectsStudentIsEnrolledIn(auth));
                    break;

                case "ALL_WITH_STATUS":
                    Object(StudentSrv.GetSubjectsAndStatusAccordingToStudent(auth));
                    break;

                case "NOT_MINE":
                    var subjectsUserIsEnrolledIn = StudentSrv.GetSubjectsStudentIsEnrolledIn(auth).Select(s => s.Id);
                    Object(SubjectSrv.GetAllSubjects().Where(s => !subjectsUserIsEnrolledIn.Contains(s.Id)));
                    break;

                default:
                    throw new Exception();
                }
            }
            catch
            {
                Error();
            }
        }
Example #2
0
        public void GradeStudent()
        {
            Console.Clear();
            Console.WriteLine("Asistente de calificaciones");
            Console.WriteLine("---------------------------");
            Console.WriteLine("");

            var subjects = SubjectSrv.GetAllSubjects();

            if (subjects.Count() == 0)
            {
                Console.WriteLine("No hay cursos registrados en el sistema");
                return;
            }

            Console.WriteLine("Materias disponibles");
            Console.WriteLine("");
            ConsolePrompts.PrintListWithIndices(subjects.Select(s => s.Name));

            Console.WriteLine("");
            var option = ConsolePrompts.ReadNumberUntilValid(
                prompt: "Numero de la materia deseada",
                min: 1,
                max: subjects.Count());

            var subject  = subjects.ElementAt(option - 1);
            var students = StudentSrv.GetStudentsEnrolledInSubject(subject.Id);

            Console.WriteLine("");

            if (students.Count() == 0)
            {
                Console.WriteLine($"No hay estudiantes inscriptos a {subject.Name}");
                return;
            }

            Console.WriteLine("Estudiantes inscriptos");
            Console.WriteLine("");
            ConsolePrompts.PrintListWithIndices(students.Select(s => $"{s.LastName}, {s.FirstName} [{s.Id}]"));

            Console.WriteLine("");
            option = ConsolePrompts.ReadNumberUntilValid(
                prompt: "Numero del estudiante",
                min: 1,
                max: subjects.Count());

            var student = students.ElementAt(option - 1);

            Console.WriteLine("");
            var grade = ConsolePrompts.ReadNumberUntilValid(
                prompt: "Nota",
                min: 1,
                max: 100);

            StudentSrv.GradeStudent(student.Id, subject.Id, grade);
            Srv.SendNotification(student.Id, $"Has recibido una calificacion! Sacaste {grade} en {subject.Name}");
            Console.WriteLine("");
            Console.WriteLine($"Se notifico a {student.LastName}, {student.FirstName} que su nota para {subject.Name} fue {grade}");
        }
Example #3
0
 public void EnrollInSubjectById(string subjectId, string auth)
 {
     try
     {
         StudentSrv.EnrollInSubject(auth, subjectId);
         Text("OK");
     }
     catch
     {
         Error();
     }
 }
Example #4
0
 public void VerifyStudent(string studentId, string auth)
 {
     try
     {
         var student = StudentSrv.GetStudentById(studentId);
         Text(student.FirstName);
     }
     catch
     {
         Error();
     }
 }
Example #5
0
 public void GetFilesForStudent(string subjectId, string auth)
 {
     try
     {
         var files = StudentSrv.GetFilesUploadedByStudent(auth, subjectId);
         Object(files);
     }
     catch
     {
         Error();
     }
 }
Example #6
0
 public void LinkUploadedFileToSubject(Tuple <string, FileRef> data, string auth)
 {
     try
     {
         StudentSrv.LinkUploadedFileToSubjectForStudent(auth, data.Item1, data.Item2);
         Text("OK");
     }
     catch
     {
         System.IO.File.Delete(data.Item2.Path);
         Text("ERROR");
     }
 }
Example #7
0
        public void GetGradesForStudent(string scope, string auth)
        {
            try
            {
                IDictionary <string, int> ret = new Dictionary <string, int>();

                var student = StudentSrv.GetStudentById(auth);
                var grades  = student.GetGrades();

                foreach (var s in grades)
                {
                    var subject = student.GetSubjects().Where(sub => sub.Id == s.Key).Single();
                    ret.Add(subject.Name, s.Value);
                }

                Object(ret);
            }
            catch
            {
                Error();
            }
        }
Example #8
0
        public void SignupStudent()
        {
            Console.Clear();
            Console.WriteLine("Registro de estudiante");
            Console.WriteLine("----------------------");
            Console.WriteLine("");

            var id = ConsolePrompts.ReadUntilValid(
                prompt: "Numero de estudiante",
                pattern: "^[0-9]{6}$",
                errorMsg: "Un numero de estudiante tiene solo seis numeros");
            var firstName = ConsolePrompts.ReadUntilValid(
                prompt: "Primer nombre",
                pattern: "^[a-zA-Z]+$",
                errorMsg: "Un nombre son letras de la A a la Z, no importan mayusculas. No se aceptan espacios ni ningun otro caracter");
            var lastName = ConsolePrompts.ReadUntilValid(
                prompt: "Primer apellido",
                pattern: "^[a-zA-Z]+$",
                errorMsg: "Un apellido son letras de la A a la Z, no importan mayusculas. No se aceptan espacios ni ningun otro caracter");

            var student = new Student()
            {
                Id        = id,
                FirstName = firstName,
                LastName  = lastName
            };

            Console.WriteLine("");

            try
            {
                StudentSrv.SignupStudent(student);
            }
            catch (DuplicateEntityException)
            {
                Console.WriteLine("Un estudiante con ese numero ya existe, cancelando la operacion...");
            }
        }