Пример #1
0
        public async Task <UpdatePriceListDetailsResponse> Handle(UpdatePriceListDetailsRequest request, CancellationToken cancellationToken)
        {
            var query = new GetPriceListDetailsQuery()
            {
                Id = request.Id
            };
            var prices = await this.queryExecutor.Execute(query);

            if (prices == null)
            {
                return(new UpdatePriceListDetailsResponse()
                {
                    Error = new Domain.ErrorHandling.ErrorModel(ErrorType.NotFound)
                });
            }
            var mappedPrices = this.mapper.Map <PriceListDetail>(request);
            var command      = new UpdatePriceListDetailsCommand()
            {
                Parameter = mappedPrices
            };
            var updatedPriceList = await this.commandExecutor.Execute(command);

            return(new UpdatePriceListDetailsResponse()
            {
                Data = this.mapper.Map <Domain.Models.PriceListDetail>(updatedPriceList)
            });
        }
Пример #2
0
        public async Task <GetPriceListDetailsByIdResponse> Handle(GetPriceListDetailsByIdRequest request, CancellationToken cancellationToken)
        {
            var query = new GetPriceListDetailsQuery()
            {
                Id        = request.Id,
                CompanyId = request.AuthenticationCompanyId
            };
            var prices = await this.queryExecutor.Execute(query);

            if (prices == null)
            {
                return(new GetPriceListDetailsByIdResponse()
                {
                    Error = new Domain.ErrorHandling.ErrorModel(ErrorType.NotFound)
                });
            }
            var mappedPrices = this.mapper.Map <PriceListDetail>(prices);

            return(new GetPriceListDetailsByIdResponse()
            {
                Data = mappedPrices
            });
        }