Beispiel #1
0
        private List <CheckoutDeliveryModel> GetDeliveriesWithPoints(CheckoutDeliveryCost checkoutDeliveryCost, DeliveryType deliveryType, int deliveryCompanyId = 0)
        {
            var deliveriesList = new List <CheckoutDeliveryModel>();

            if (checkoutDeliveryCost != null && checkoutDeliveryCost.deliveries != null)
            {
                for (int i = 0; i < checkoutDeliveryCost.deliveries.Count; i++)
                {
                    var deliveryId = 0;
                    if (!int.TryParse(checkoutDeliveryCost.deliveries[i], out deliveryId))
                    {
                        continue;
                    }

                    var minDeliveryTerm = 0;
                    if (!int.TryParse(checkoutDeliveryCost.minTerms[i], out minDeliveryTerm))
                    {
                        continue;
                    }

                    var maxDeliveryTerm = 0;
                    if (!int.TryParse(checkoutDeliveryCost.maxTerms[i], out maxDeliveryTerm))
                    {
                        continue;
                    }

                    var cost = 0f;
                    if (!float.TryParse(checkoutDeliveryCost.costs[i], NumberStyles.Float, CultureInfo.InvariantCulture, out cost))
                    {
                        continue;
                    }

                    //если нужна выборка по компании, но данная доставка к ней не относится
                    if (deliveryCompanyId != 0 && deliveryId != deliveryCompanyId)
                    {
                        continue;
                    }

                    deliveriesList.Add(new CheckoutDeliveryModel
                    {
                        DeliveryId           = deliveryId,
                        Cost                 = cost,
                        Code                 = checkoutDeliveryCost.codes[i],
                        MaxDeliveryTerm      = maxDeliveryTerm,
                        MinDeliveryTerm      = minDeliveryTerm,
                        Address              = checkoutDeliveryCost.addresses[i],
                        AdditionalInfo       = checkoutDeliveryCost.additionalInfo[i],
                        Npp                  = checkoutDeliveryCost.npp[i],
                        CheckoutDeliveryType = deliveryType
                    });
                }
            }

            return(deliveriesList);
        }
Beispiel #2
0
        private List <CheckoutDeliveryModel> GetDeliveriesWithoutPoints(CheckoutDeliveryCost checkoutDeliveryCost, DeliveryType deliveryType, int deliveryCompanyId = 0)
        {
            if (checkoutDeliveryCost != null)
            {
                var isValid = true;

                var deliveryId = 0;
                isValid &= int.TryParse(checkoutDeliveryCost.deliveryId, out deliveryId);

                var minDeliveryTerm = 0;
                isValid &= int.TryParse(checkoutDeliveryCost.minDeliveryTerm, out minDeliveryTerm);

                var maxDeliveryTerm = 0;
                isValid &= int.TryParse(checkoutDeliveryCost.maxDeliveryTerm, out maxDeliveryTerm);

                var cost = 0f;
                isValid &= float.TryParse(checkoutDeliveryCost.cost, NumberStyles.Float, CultureInfo.InvariantCulture, out cost);

                //если нужна выборка по компании, но данная доставка к ней не относится
                isValid &= deliveryCompanyId == 0 || (deliveryCompanyId != 0 && deliveryId == deliveryCompanyId);

                if (isValid)
                {
                    return(new List <CheckoutDeliveryModel>
                    {
                        new CheckoutDeliveryModel
                        {
                            DeliveryId = deliveryId,
                            Cost = cost,
                            MaxDeliveryTerm = maxDeliveryTerm,
                            MinDeliveryTerm = minDeliveryTerm,
                            CheckoutDeliveryType = deliveryType
                        }
                    });
                }
            }

            return(new List <CheckoutDeliveryModel>());
        }