Esempio n. 1
0
        public StudentDepartmentDTOenrolled CreateStudentDepartment(StudentDepartmentDTO studentDepartmentDTO)
        {
            logger.Info($"Searching for student with ID {studentDepartmentDTO.StudentID} over student service, create student department, student department service");
            Student student = studentsService.GetStudent(studentDepartmentDTO.StudentID);

            logger.Info($"searching for department with id {studentDepartmentDTO.DepartmentID} over student service, create student department, student department service");
            Department department = departmentsService.GetDepartmentId(studentDepartmentDTO.DepartmentID);

            logger.Info($"Converting from DTO, createStudent department, student department service");
            StudentDepartment studentDepartment = new StudentDepartment()
            {
                EnrolmentTime = studentDepartmentDTO.EnrolmentTime,
                Students      = student,
                Departments   = department
            };

            logger.Info($"Sending student {studentDepartment.Students.UserName} {studentDepartment.Departments.DepartmentName} to db over student department repository, student" +
                        $"department service, create student department");
            db.StudentDepartmentsRepository.Insert(studentDepartment);
            logger.Info($"Saving student {studentDepartment.Students.UserName} {studentDepartment.Departments.DepartmentName} to db over student department repository, student" +
                        $"department service, create student department");
            db.Save();
            logger.Info($"Converting student department to DTO, create student department, student department service");
            StudentDepartmentDTOenrolled studentEnrolled = new StudentDepartmentDTOenrolled()
            {
                Student             = Utilities.ConverterDTO.SimpleDTOConverter <StudentDTOIn>(studentDepartment.Students),
                Department          = Utilities.ConverterDTO.SimpleDTOConverter <DepartmentDTOStudent>(studentDepartment.Departments),
                Grade               = Utilities.ConverterDTO.SimpleDTOConverter <GradeDTOOut>(studentDepartment.Departments.Grades),
                StudentDepartmentId = studentDepartment.Id
            };

            return(studentEnrolled);
        }
        public IHttpActionResult PostEnrollStudent(StudentDepartmentDTO student)
        {
            logger.Info("Enrolling student to department, studentdepartment service, Post enroll Student, studentdepartment controller");
            StudentDepartmentDTOenrolled studentEnrolled = studentDepartmentsService.CreateStudentDepartment(student);

            return(Created("", studentEnrolled));
        }