Exemplo n.º 1
0
        public async Task <DeletePriceListByIdResponse> Handle(DeletePriceListByIdRequest request, CancellationToken cancellationToken)
        {
            var query = new GetPriceQuery()
            {
                Id = request.Id
            };
            var prices = await this.queryExecutor.Execute(query);

            if (prices == null)
            {
                return(new DeletePriceListByIdResponse()
                {
                    Error = new Domain.ErrorHandling.ErrorModel(ErrorType.NotFound)
                });
            }
            var mappedPrices = this.mapper.Map <DataAccess.Entities.PriceList>(request);
            var command      = new DeletePriceListCommand()
            {
                Parameter = mappedPrices
            };
            var deletedPriceList = await this.commandExecutor.Execute(command);

            return(new DeletePriceListByIdResponse()
            {
                Data = deletedPriceList
            });
        }
Exemplo n.º 2
0
        public async Task <CreatePriceListResponse> Handle(CreatePriceListRequest request, CancellationToken cancellationToken)
        {
            //if (request.AuthenticationRole == "UserHotel" || request.AuthenticationRole == "UserAdmin")
            //{
            //    return new CreatePriceListResponse
            //    {
            //        Error = new ErrorModel(ErrorType.Forbidden)
            //    };

            //}

            var query = new GetPriceQuery()
            {
                CompanyId         = request.AuthenticationCompanyId,
                LaundryId         = request.LaundryId,
                WouldLikeToCreate = true
            };
            var lastPriceList = await this.queryExecutor.Execute(query);

            if (lastPriceList != null)
            {
                lastDocNumber = lastPriceList.DocNumber;
            }
            else
            {
                lastDocNumber = "0/0/0";
            }
            request.Number = docNumCreator.DocumentNumberCreator(lastDocNumber);

            var mappedPrices = this.mapper.Map <PriceList>(request);
            var command      = new CreatePriceListCommand()
            {
                Parameter = mappedPrices
            };
            var createdPriceList = await this.commandExecutor.Execute(command);

            return(new CreatePriceListResponse()
            {
                Data = this.mapper.Map <Domain.Models.PriceList>(createdPriceList)
            });
        }
Exemplo n.º 3
0
        public async Task <GetPriceListByIdResponse> Handle(GetPriceListByIdRequest request, CancellationToken cancellationToken)
        {
            var query = new GetPriceQuery()
            {
                Id = request.Id
            };
            var prices = await this.queryExecutor.Execute(query);

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

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