public async Task <UniversityResponseModel> PutUniversity( int universityId, [FromForm] UniversityRequestModel model, CancellationToken cancellationToken ) { cancellationToken.ThrowIfCancellationRequested(); var command = new UpdateUniversityCommand( universityId, model.Name, model.ShortName, model.Description ); await _mediator.Send(command, cancellationToken); var query = new FindUniversityByIdQuery(universityId); var university = await _mediator.Send(query, cancellationToken); var response = _mapper.Map <UniversityResponseModel>(university); return(response); }
public async Task <UniversityResponseModel> GetUniversity( int universityId, CancellationToken cancellationToken ) { cancellationToken.ThrowIfCancellationRequested(); var query = new FindUniversityByIdQuery(universityId); var university = await _mediator.Send(query, cancellationToken); if (university == null) { throw new NotFoundException(nameof(university), universityId); } var response = _mapper.Map <UniversityResponseModel>(university); return(response); }