public FacultyResponseDTO Update(UpdateFacultyRequestDTO requestDTO) { var old = this.FindOneByUUID(requestDTO.uuid); if (old == null) { throw new EntityNotFoundException($"Faculty with uuid {requestDTO.uuid} doesn't exist!", GeneralConsts.MICROSERVICE_NAME); } var similar = this.FindOneByNameAndCity(requestDTO.name, requestDTO.city); if (similar != null && similar.name != old.name) { throw new EntityNotFoundException($"Faculty with name {requestDTO.name} in city {requestDTO.city} already exists!", GeneralConsts.MICROSERVICE_NAME); } Faculty faculty = new Faculty() { uuid = requestDTO.uuid, name = requestDTO.name, phone = requestDTO.phone, city = requestDTO.city }; faculty = this._queryExecutor.Execute <Faculty>(DatabaseConsts.USER_SCHEMA, this._sqlCommands.UPDATE_FACULTY(faculty), this._modelMapper.MapToFaculty); return(this._autoMapper.Map <FacultyResponseDTO>(faculty)); }
public ActionResult <FacultyResponseDTO> HandleUpdateFaculty(UpdateFacultyRequestDTO requestDTO) { return(Ok(this._facultyService.Update(requestDTO))); }