Exemple #1
0
        public OrderDto convertToAPIOrder(
            Order vodovozOrder,
            DateTime addedToRouteListTime,
            SmsPaymentStatus?smsPaymentStatus,
            FastPaymentStatus?qrPaymentDtoStatus)
        {
            var pairOfSplitedLists = SplitDeliveryItems(vodovozOrder.OrderEquipments);

            var deliveryPointPhones = vodovozOrder.DeliveryPoint.Phones
                                      .GroupBy(p => p.DigitsNumber)
                                      .Select(x => new PhoneDto {
                Number = "+7" + x.First().DigitsNumber, PhoneType = PhoneDtoType.DeliveryPoint
            })
                                      .ToList();

            var counterpartyPhones = vodovozOrder.Client.Phones
                                     .GroupBy(p => p.DigitsNumber)
                                     .Select(x => new PhoneDto {
                Number = "+7" + x.First().DigitsNumber, PhoneType = PhoneDtoType.Counterparty
            })
                                     .ToList();

            var apiOrder = new OrderDto
            {
                OrderId              = vodovozOrder.Id,
                SmsPaymentStatus     = _smsPaymentConverter.convertToAPIPaymentStatus(smsPaymentStatus),
                QRPaymentStatus      = _qrPaymentConverter.ConvertToAPIPaymentStatus(qrPaymentDtoStatus),
                DeliveryTime         = vodovozOrder.TimeDelivered?.ToString("HH:mm:ss"),
                FullBottleCount      = vodovozOrder.Total19LBottlesToDeliver,
                EmptyBottlesToReturn = (vodovozOrder.BottlesReturn ?? 0) + vodovozOrder.BottlesByStockCount,
                Counterparty         = vodovozOrder.Client.FullName,
                PhoneNumbers         = deliveryPointPhones.Concat(counterpartyPhones),
                PaymentType          = _paymentTypeConverter.ConvertToAPIPaymentType(vodovozOrder.PaymentType, vodovozOrder.PaymentByCardFrom),
                Address              = _deliveryPointConverter.ExtractAPIAddressFromDeliveryPoint(vodovozOrder.DeliveryPoint),
                OrderComment         = vodovozOrder.Comment,
                OrderSum             = vodovozOrder.OrderSum,
                OrderSaleItems       = PrepareSaleItemsList(vodovozOrder.OrderItems),
                OrderDeliveryItems   = pairOfSplitedLists.orderDeliveryItems,
                OrderReceptionItems  = pairOfSplitedLists.orderReceptionItems,
                IsFastDelivery       = vodovozOrder.IsFastDelivery,
                AddedToRouteListTime = addedToRouteListTime.ToString("dd.MM.yyyyTHH:mm:ss"),
                Trifle        = vodovozOrder.Trifle ?? 0,
                SignatureType = _signatureTypeConverter.ConvertToApiSignatureType(vodovozOrder.SignatureType)
            };

            return(apiOrder);
        }
Exemple #2
0
        public OrderDto convertToAPIOrder(Vodovoz.Domain.Orders.Order vodovozOrder, SmsPaymentStatus?smsPaymentStatus)
        {
            var pairOfSplitedLists = SplitDeliveryItems(vodovozOrder.OrderEquipments);

            var apiOrder = new OrderDto()
            {
                OrderId              = vodovozOrder.Id,
                SmsPaymentStatus     = _smsPaymentConverter.convertToAPIPaymentStatus(smsPaymentStatus),
                DeliveryTime         = vodovozOrder.TimeDelivered?.ToString("HH:mm:ss"),
                FullBottleCount      = vodovozOrder.Total19LBottlesToDeliver,
                EmptyBottlesToReturn = vodovozOrder.BottlesReturn ?? 0,
                Counterparty         = vodovozOrder.Client.FullName,
                PhoneNumbers         = vodovozOrder.DeliveryPoint.Phones.Concat(vodovozOrder.Client.Phones).Select(x => "+7" + x.DigitsNumber),
                PaymentType          = _paymentTypeConverter.ConvertToAPIPaymentType(vodovozOrder.PaymentType, vodovozOrder.PaymentByCardFrom),
                Address              = _deliveryPointConverter.ExtractAPIAddressFromDeliveryPoint(vodovozOrder.DeliveryPoint),
                OrderComment         = vodovozOrder.Comment,
                OrderSum             = vodovozOrder.ActualTotalSum,
                OrderSaleItems       = PrepareSaleItemsList(vodovozOrder.OrderItems),
                OrderDeliveryItems   = pairOfSplitedLists.orderDeliveryItems,
                OrderReceptionItems  = pairOfSplitedLists.orderReceptionItems
            };

            return(apiOrder);
        }