public async Task <UpdateInstrumentResponse> Handle(UpdateInstrumentRequest request, CancellationToken cancellationToken) { var query = new GetInstrumentByIdQuery() { Id = request.instrumentId }; var gotInstrument = await this.queryExecutor.Execute(query); if (gotInstrument == null) { return new UpdateInstrumentResponse() { Data = null } } ; var command = new UpdateInstrumentCommand() { Parameter = this.mapper.Map(request, gotInstrument) }; var instrument = await this.commandExecutor.Execute(command); return(new UpdateInstrumentResponse() { Data = this.mapper.Map <Domain.Models.Instrument>(instrument) }); } }
public async Task <GetInstrumentByIdResponse> Handle(GetInstrumentByIdRequest request, CancellationToken cancellationToken) { var query = new GetInstrumentByIdQuery() { Id = request.InstrumentId }; var instrument = await this.queryExecutor.Execute(query); var mappedInstrument = this.mapper.Map <Domain.Models.Instrument>(instrument); var response = new GetInstrumentByIdResponse() { Data = mappedInstrument }; return(response); }