public async Task <UpdateMyInstrumentResponse> Handle(UpdateMyInstrumentRequest request, CancellationToken cancellationToken) { var query = new GetMyInstrumentByIdQuery() { Id = request.myInstrumentId }; var gotMyInstrument = await this.queryExecutor.Execute(query); if (gotMyInstrument == null) { return new UpdateMyInstrumentResponse() { Data = null } } ; var command = new UpdateMyInstrumentCommand() { Parameter = this.mapper.Map(request, gotMyInstrument) }; var myInstrument = await this.commandExecutor.Execute(command); return(new UpdateMyInstrumentResponse() { Data = this.mapper.Map <Domain.Models.MyInstrument>(myInstrument) }); } }
public async Task <GetMyInstrumentByIdResponse> Handle(GetMyInstrumentByIdRequest request, CancellationToken cancellationToken) { var query = new GetMyInstrumentByIdQuery() { Id = request.MyInstrumentId }; var myInstrument = await this.queryExecutor.Execute(query); var mappedMyInstrument = this.mapper.Map <Domain.Models.MyInstrument>(myInstrument); var response = new GetMyInstrumentByIdResponse() { Data = mappedMyInstrument }; return(response); }
public static async Task <bool> CheckIfCorrect <T>(T request, IQueryExecutor queryExecutor) where T : IAddAndUpdateInstalledStringProperties { var queryNewInstalledString = new GetInstalledStringByPositionAndMyInstrumentQuery() { MyInstrumentID = request.MyInstrumentID, StringPosition = request.StringPosition }; var gotNewInstalledString = await queryExecutor.Execute(queryNewInstalledString); var querySound = new GetSoundByIdQuery() { Id = request.SoundID }; var gotSound = await queryExecutor.Execute(querySound); var queryMyInstrument = new GetMyInstrumentByIdQuery() { Id = request.MyInstrumentID }; var gotMyInstrument = await queryExecutor.Execute(queryMyInstrument); var queryString = new GetStringByIdQuery() { Id = request.StringID }; var gotString = await queryExecutor.Execute(queryString); if (gotNewInstalledString == null && gotSound != null && gotMyInstrument != null && gotString != null) { return(true); } else { return(false); } }