Ejemplo n.º 1
0
        public StudyPlan Update(StudyPlan studyPlan)
        {
            var existentStudyPlan = _studyPlanRepository.Get(studyPlan.Id);

            if (existentStudyPlan == null)
            {
                throw new Exception("There is no Study Plan with that ID");
            }

            var updatedValue = _studyPlanRepository.Update(studyPlan);

            return(updatedValue);
        }
Ejemplo n.º 2
0
        public Course AddCourse(Guid teacherId, Guid subjectId, Guid studyPlanId)
        {
            // Validations
            var teacher = _teacherRepository.Get(teacherId);

            if (teacher == null)
            {
                throw new Exception("No Teacher Found");
            }

            var subject = _subjectRepository.Get(subjectId);

            if (subject == null)
            {
                throw new Exception("No Subject Found");
            }

            var studyPlan = _studyPlanRepository.Get(studyPlanId);

            if (studyPlan == null)
            {
                throw new Exception("No StudyPlan Found");
            }

            // Execution
            return(_courseGenerationService.DoGenerateCourse(teacher, subject, studyPlan));
        }
Ejemplo n.º 3
0
        public ActionResult <IEnumerable <StudyPlanDto> > Get(string id)
        {
            if (!Guid.TryParse(id, out var idRequested))
            {
                return(BadRequest("Invalid ID Format"));
            }

            var objectRequested = _studyPlanRepository.Get(idRequested);

            if (objectRequested == null)
            {
                return(NotFound());
            }

            return(Ok(_mapper.Map <StudyPlanDto>(objectRequested)));
        }
Ejemplo n.º 4
0
        public Enrollment Add(Guid studentId, Guid studyPlanId)
        {
            // Validations
            var student = _studentRepository.Get(studentId);

            if (student == null)
            {
                throw new Exception("No Student Found");
            }

            var studyPlan = _studyPlanRepository.Get(studyPlanId);

            if (studyPlan == null)
            {
                throw new Exception("No StudyPlan Found");
            }

            return(_registrationAndEnrollmentService.DoEnrollmentAndRegistration(student, studyPlan));
        }
Ejemplo n.º 5
0
 public async Task <StudyPlan> GetById(int studyPlanId)
 {
     return(await _studyPlanRepository.Get(sp => sp.Id == studyPlanId));
 }