public async Task <IActionResult> Create([FromBody] Address address)
        {
            var shipmentInformation = await _shipmentRepository.CreateAsync(address);

            _logger.LogInformation("Shipment {TrackingNumber} was created to deliver at {DeliverAddress}", shipmentInformation.TrackingNumber, shipmentInformation.DeliveryAddress);

            return(CreatedAtAction(nameof(Get), new { trackingNumber = shipmentInformation.TrackingNumber }, shipmentInformation));
        }
        public async Task <OrderConfirmation> CreateAsync(Order createdOrder)
        {
            var confirmationId = await _orderRepository.CreateAsync(createdOrder);

            var shipmentInformation = await _shipmentRepository.CreateAsync(createdOrder);

            var orderConfirmation = new OrderConfirmation
            {
                ConfirmationId      = confirmationId,
                ShipmentInformation = shipmentInformation,
                Customer            = createdOrder.Customer
            };

            return(orderConfirmation);
        }
Exemplo n.º 3
0
        public async Task <int> CreateAsync(ShipmentDTO item)
        {
            item.DateTime = DateTime.Now;
            int shipmentId = await _repo.CreateAsync(_mapper.Map <Shipment>(item));

            var shipment = await ReadAsync(shipmentId);

            if (shipment.Order.UserId == item.RepicientApplicationUserId)
            {
                await _statusesService.SetDelivered(shipment.OrderId, null);
            }
            else if (shipment.Repicient.UserName.Contains("Courier", StringComparison.OrdinalIgnoreCase))
            {
                await _statusesService.SetByStatusString(shipment.OrderId, "Передан курьеру", null);
            }

            return(shipmentId);
        }