public async Task <UpdateInstalledStringResponse> Handle(UpdateInstalledStringRequest request, CancellationToken cancellationToken)
        {
            var query = new GetInstalledStringByPositionAndMyInstrumentQuery()
            {
                MyInstrumentID = request.routeMyInstrumentID,
                StringPosition = request.routeStringPosition
            };
            var gotInstalledString = await this.queryExecutor.Execute(query);

            if (!await CheckInstalledString.CheckIfCorrect(request, queryExecutor) && gotInstalledString != null)
            {
                return new UpdateInstalledStringResponse()
                       {
                           Error = new Domain.ErrorModel(ErrorType.Conflict)
                       }
            }
            ;
            var command = new UpdateInstalledStringCommand()
            {
                Parameter = mapper.Map(request, gotInstalledString)
            };
            var installedString = await this.commandExecutor.Execute(command);

            return(new UpdateInstalledStringResponse()
            {
                Data = mapper.Map <Domain.Models.InstalledString>(installedString)
            });
        }
    }
Example #2
0
        public async Task <AddInstalledStringResponse> Handle(AddInstalledStringRequest request, CancellationToken cancellationToken)
        {
            if (!await CheckInstalledString.CheckIfCorrect(request, queryExecutor))
            {
                return new AddInstalledStringResponse()
                       {
                           Error = new Domain.ErrorModel(ErrorType.Conflict)
                       }
            }
            ;

            var installedString = this.mapper.Map <DataAccess.Entities.InstalledString>(request);
            var command         = new AddInstalledStringCommand()
            {
                Parameter = installedString
            };
            var installedStringFromDb = await this.commandExecutor.Execute(command);

            return(new AddInstalledStringResponse()
            {
                Data = mapper.Map <Domain.Models.InstalledString>(installedStringFromDb)
            });
        }
    }