public DepartmentResponseDTO Update(UpdateDepartmentRequestDTO requestDTO)
        {
            var old = this.FindOneByUUID(requestDTO.uuid);

            if (old == null)
            {
                throw new EntityNotFoundException($"Department with uuid {requestDTO.uuid} doesn't exist!", GeneralConsts.MICROSERVICE_NAME);
            }

            if (this._facultyService.GetOneByUuid(requestDTO.facultyUUID) == null)
            {
                throw new EntityNotFoundException($"Faculty with uuid {requestDTO.facultyUUID} doesn't exists!", GeneralConsts.MICROSERVICE_NAME);
            }

            var similar = this.FindOneByNameAndfaculty(requestDTO.name, requestDTO.facultyUUID);

            if (similar != null && similar.name != old.name)
            {
                throw new EntityNotFoundException($"Department with name {requestDTO.name} with facultyUUID {requestDTO.facultyUUID} already exists!", GeneralConsts.MICROSERVICE_NAME);
            }

            Faculty faculty = this._autoMapper.Map <Faculty>(this._facultyService.GetOneByUuid(requestDTO.facultyUUID));

            Department department = new Department()
            {
                uuid    = requestDTO.uuid,
                name    = requestDTO.name,
                faculty = faculty
            };

            department = this._queryExecutor.Execute <Department>(DatabaseConsts.USER_SCHEMA, this._sqlCommands.UPDATE_DEPARTMENT(department), this._modelMapper.MapToDepartmentAfterInsert);
            department = this._queryExecutor.Execute <Department>(DatabaseConsts.USER_SCHEMA, this._sqlCommands.GET_DEPARTMENT_BY_UUID(department.uuid), this._modelMapper.MapToDepartment);

            return(this._autoMapper.Map <DepartmentResponseDTO>(department));
        }
 public ActionResult <DepartmentResponseDTO> HandleUpdateDepartment(UpdateDepartmentRequestDTO requestDTO)
 {
     return(Ok(this._departmentService.Update(requestDTO)));
 }