Ejemplo n.º 1
0
            public async Task <GoodsApiDTO> Handle(
                [NotNull] GetGoodsByIdQuery request,
                CancellationToken cancellationToken)
            {
                Guard.NotNull(request, nameof(request));

                var goodsItem = await _goodsRepository.GetByIdAsync(
                    request.Id,
                    cancellationToken).ConfigureAwait(false);

                return(_mapper.Map <GoodsApiDTO>(goodsItem));
            }
Ejemplo n.º 2
0
            protected override async Task Handle(
                [NotNull] DeleteGoodsItemByIdCommand request,
                CancellationToken cancellationToken)
            {
                Guard.NotNull(request, nameof(request));

                var goodsItem = await _goodsRepository
                                .GetByIdAsync(request.Id, cancellationToken)
                                .ConfigureAwait(false);

                if (goodsItem != null)
                {
                    await _goodsRepository
                    .DeleteAsync(goodsItem, cancellationToken)
                    .ConfigureAwait(false);
                }
            }