public DeliveryMapperTests()
        {
            _mockOrderMapper        = new Mock <IOrderMapper>();
            _mockAccessWindowMapper = new Mock <IAccessWindowMapper>();
            _mockRecipientMapper    = new Mock <IRecipientMapper>();

            _deliveryMapper = new DeliveryMapper(_mockOrderMapper.Object,
                                                 _mockRecipientMapper.Object,
                                                 _mockAccessWindowMapper.Object);
        }
Пример #2
0
        public async Task <IActionResult> GetDeliveryDetails(string transactionId, CancellationToken cancellationToken)
        {
            var query = new GetDeliveryByIdQuery(transactionId);

            var result = await getDeliveryByIdQueryHandler.HandleAsync(query, cancellationToken).ConfigureAwait(false);

            if (result == null)
            {
                return(NotFound());
            }

            Response.Headers.Add(CustomHttpHeaderKeys.EntityVersion, result.DocumentVersion);

            var response = DeliveryMapper.ToApiContract(result.Delivery);

            return(Ok(response));
        }
Пример #3
0
        public async Task <GetDeliveryByIdQueryResult> HandleAsync(GetDeliveryByIdQuery query, CancellationToken cancellationToken)
        {
            using (var session = documentStore.OpenAsyncSession())
            {
                var deliveryDocument = await session.LoadDeliveryAsync(query.TransactionId, cancellationToken).ConfigureAwait(false);

                if (deliveryDocument == null)
                {
                    return(null);
                }

                var changeVector = session.Advanced.GetChangeVectorFor(deliveryDocument);
                var delivery     = DeliveryMapper.ToServiceContract(documentStore, deliveryDocument);

                return(new GetDeliveryByIdQueryResult(delivery, changeVector));
            }
        }
Пример #4
0
 public DeliveryService()
 {
     ctx            = new ProductionContext();
     deliveryMapper = new DeliveryMapper();
 }