//POST METHODS
        public CourseStudentResponseDTO CreateStudentOnCourse(CreateCourseStudentRequestDTO request)
        {
            //provera da li postoji kurs
            CourseResponseDTO  course    = this._courseService.GetOneByUuid(request.courseUUID);
            String             courseDep = course.subject.department.uuid;
            StudentResponseDTO student;

            //provera da li postoji student
            try {
                student = this._httpClientService.SendRequest <StudentResponseDTO>(HttpMethod.Get, "http://localhost:40001/api/users/students/" + request.studentUUID, new UserPrincipal(_httpContextAccessor.HttpContext).token).Result;
            }
            catch
            {
                throw new EntityNotFoundException("Student with uuid " + request.studentUUID + " doesn't exist", GeneralConsts.MICROSERVICE_NAME);
            }
            String studentDep = student.departmentUUID;

            //provera da li su predmet i student na istom departmanu
            if (studentDep != courseDep)
            {
                throw new EntityNotFoundException("Student with uuid " + request.studentUUID + " and course with uuid: " + request.courseUUID + " are not on the same department", GeneralConsts.MICROSERVICE_NAME);
            }
            //ako student vrsi zahtev, moze da upise samo sebe
            UserPrincipal up = new UserPrincipal(_httpContextAccessor.HttpContext);

            if (up.role == RoleConsts.ROLE_STUDENT_ONLY)
            {
                checkStudent(student.uuid, up.uuid);
            }
            //provera da li vec postoji student na tom kursu
            CourseStudent existingCourseStudent = this.FindStudentOnCourse(request.courseUUID, request.studentUUID);

            if (existingCourseStudent != null)
            {
                if (existingCourseStudent.activeStudent == false)
                {
                    CourseStudent updatedStudent = this._autoMapper.Map <CourseStudent>(request);
                    updatedStudent.activeStudent = true;
                    updatedStudent.course        = new Course()
                    {
                        uuid = request.courseUUID
                    };
                    updatedStudent.student = new Student()
                    {
                        uuid = request.studentUUID
                    };
                    updatedStudent = this._queryExecutor.Execute <CourseStudent>(DatabaseConsts.USER_SCHEMA, this._sqlCommands.UPDATE_STUDENT_ON_COURSE(updatedStudent), this._modelMapper.MapToCourseStudent);
                    CourseStudentResponseDTO updatedResponse = this._autoMapper.Map <CourseStudentResponseDTO>(updatedStudent);
                    return(connectWithUser(updatedResponse));
                }
                else
                {
                    throw new EntityAlreadyExistsException("Student with uuid " + request.studentUUID + " already exists in course with uuid " + request.courseUUID, GeneralConsts.MICROSERVICE_NAME);
                }
            }
            CourseStudent newCourseStudent = this._autoMapper.Map <CourseStudent>(request);

            newCourseStudent.activeStudent = true;
            newCourseStudent.course        = new Course()
            {
                uuid = request.courseUUID
            };
            newCourseStudent.student = new Student()
            {
                uuid = request.studentUUID
            };
            newCourseStudent = this._queryExecutor.Execute <CourseStudent>(DatabaseConsts.USER_SCHEMA, this._sqlCommands.CREATE_STUDENT_ON_COURSE(newCourseStudent), this._modelMapper.MapToCourseStudent);
            CourseStudentResponseDTO response = this._autoMapper.Map <CourseStudentResponseDTO>(newCourseStudent);

            response.course = this._courseService.GetOneByUuid(response.course.uuid);
            return(connectWithUser(response));
        }
 public ActionResult <CourseStudentResponseDTO> HandleCreateStudentOnCourse(CreateCourseStudentRequestDTO request)
 {
     return(Ok(this._courseStudentsService.CreateStudentOnCourse(request)));
 }