示例#1
0
        private void PopulateDto(data.bvc_Order old, OrderDTO o)
        {
            o.AffiliateID = old.AffiliateID == 0 ? string.Empty : old.AffiliateID.ToString();
            BVC2004Address oldBilling = new BVC2004Address();
            oldBilling.FromXmlString(old.BillingAddress);
            if (oldBilling != null)
            {
                oldBilling.CopyTo(o.BillingAddress, EFConnString(settings.SourceConnectionString()));
            }
            o.Bvin = old.ID.ToString() ?? string.Empty;
            o.CustomProperties = new List<CustomPropertyDTO>();
            o.FraudScore = 0;
            //o.Id = old.ID;
            o.Instructions = old.Instructions;
            o.IsPlaced = old.StatusCode == 3;
            o.LastUpdatedUtc = old.LastUpdated ?? DateTime.UtcNow;
            o.OrderNumber = old.ID.ToString() ?? string.Empty;
            if (old.OrderDiscountsTotal != 0)
            {
                o.OrderDiscountDetails.Add(new DiscountDetailDTO() { Amount = -1 * ((decimal)old.OrderDiscountsTotal), Description = "BVC 2004 Order Discounts", Id = new Guid() });
            }
            o.PaymentStatus = OrderPaymentStatusDTO.Unknown;
            switch (old.PaymentStatus)
            {
                case 0:
                case 99:
                    o.PaymentStatus = OrderPaymentStatusDTO.Unknown;
                    break;
                case 10:
                case 20:
                    o.PaymentStatus = OrderPaymentStatusDTO.Unpaid;
                    break;
                case 30:
                    o.PaymentStatus = OrderPaymentStatusDTO.Paid;
                    break;
            }

            data.bvc_Package firstPackage = old.bvc_Package.FirstOrDefault();
            if (firstPackage != null)
            {
                BVC2004Address oldShipping = new BVC2004Address();
                oldShipping.FromXmlString(firstPackage.DestinationAddress);
                if (oldShipping != null) oldShipping.CopyTo(o.ShippingAddress, EFConnString(settings.SourceConnectionString()));
                o.ShippingMethodDisplayName = firstPackage.ShippingMethodName;
                o.ShippingMethodId = string.Empty;
                o.ShippingProviderId = string.Empty;
                o.ShippingProviderServiceCode = firstPackage.ShippingServiceCode;
            }

            o.ShippingStatus = OrderShippingStatusDTO.Unknown;
            switch (old.ShippingStatus)
            {
                case 0:
                    o.ShippingStatus = OrderShippingStatusDTO.Unknown;
                    break;
                case 1:
                    o.ShippingStatus = OrderShippingStatusDTO.Unshipped;
                    break;
                case 2:
                    o.ShippingStatus = OrderShippingStatusDTO.PartiallyShipped;
                    break;
                case 3:
                    o.ShippingStatus = OrderShippingStatusDTO.FullyShipped;
                    break;
                case 4:
                    o.ShippingStatus = OrderShippingStatusDTO.NonShipping;
                    break;
            }
            o.StatusCode = string.Empty;
            o.StatusName = "Uknown";
            switch (old.StatusCode)
            {

                case -1: //com.bvsoftware.bvc2004.OrderStatusCode.Canceled
                    o.StatusCode = "A7FFDB90-C566-4cf2-93F4-D42367F359D5";
                    o.StatusName = "On Hold";
                    break;
                case 3: //com.bvsoftware.bvc2004.OrderStatusCode.Completed
                    o.StatusCode = "09D7305D-BD95-48d2-A025-16ADC827582A";
                    o.StatusName = "Complete";
                    break;
                case 2: //com.bvsoftware.bvc2004.OrderStatusCode.InProcess
                    o.StatusCode = "F37EC405-1EC6-4a91-9AC4-6836215FBBBC";
                    o.StatusName = "In Process";
                    break;
                case 1:
                case 100:
                case 200: //com.bvsoftware.bvc2004.OrderStatusCode.OnHold
                    o.StatusCode = "88B5B4BE-CA7B-41a9-9242-D96ED3CA3135";
                    o.StatusName = "On Hold";
                    break;
                case 999: //com.bvsoftware.bvc2004.OrderStatusCode.Void
                    o.StatusCode = "A7FFDB90-C566-4cf2-93F4-D42367F359D5";
                    o.StatusName = "Void";
                    break;
            }

            o.ThirdPartyOrderId = string.Empty;
            o.TimeOfOrderUtc = old.TimeOfOrder ?? DateTime.UtcNow;
            o.TotalHandling = (decimal)old.HandlingFee;
            o.TotalShippingBeforeDiscounts = ((decimal)old.ShippingTotal + (decimal)old.ShippingDiscountsTotal);
            o.ShippingDiscountDetails.Add(new DiscountDetailDTO() { Amount = -1 * (decimal)old.ShippingDiscountsTotal, Description = "BVC2004 Shipping Discount", Id = new Guid() });
            o.TotalTax = (decimal)old.TaxTotal;
            o.TotalTax2 = 0;
            o.UserEmail = string.Empty;
            o.UserID = old.UserID.ToString();

            wl(" - Coupons for Order " + old.ID.ToString());
            o.Coupons = TranslateCoupons(old);

            wl(" - Items For order " + old.ID.ToString());
            o.Items = TranslateItems(old);
            LineItemHelper.SplitTaxesAcrossItems((decimal)old.TaxTotal, (decimal)old.SubTotal, o.Items);

            wl(" - Notes For order " + old.ID.ToString());
            o.Notes = TranslateNotes(old);

            wl(" - Packages For order " + old.ID.ToString());
            o.Packages = TranslatePackages(old);

        }
示例#2
0
        private void ImportSingleOrder(data.bvc_Order old)
        {
            if (old == null) return;
            wl("Processing Order: " + old.ID.ToString());

            OrderDTO o = new OrderDTO();            
            PopulateDto(old, o);
            if (o != null)
            {
                Api proxy = GetBV6Proxy();
                var res = proxy.OrdersCreate(o);
                if (res != null)
                {
                    if (res.Errors.Count > 0)
                    {
                        DumpErrors(res.Errors);
                        wl("FAILED");
                    }
                    else
                    {
                        wl("SUCCESS");
                        ImportOrderTransactions(o.Bvin, o.OrderNumber, old);
                    }
                }

            }
        }
示例#3
0
        private void ImportSingleOrder(OrderDTO old)
        {
            if (old == null) return;
            wl("Processing Order: " + old.OrderNumber);

            OrderDTO o = old;            
            if (o != null)
            {
                Api proxy = GetMerchantTribeProxy();
                var res = proxy.OrdersCreate(o);
                if (res != null)
                {
                    if (res.Errors.Count > 0)
                    {
                        DumpErrors(res.Errors);
                        wl("FAILED");
                    }
                    else
                    {
                        wl("SUCCESS");
                        ImportOrderTransactions(o.Bvin, o.OrderNumber);
                    }
                }

            }
        }        
示例#4
0
        private void PopulateDto(data.bvc_Order old, OrderDTO o)
        {
            o.AffiliateID = old.AffiliateId ?? string.Empty;
            BV5Address oldBilling = new BV5Address();
            oldBilling.FromXmlString(old.BillingAddress);
            if (oldBilling != null)
            {
                oldBilling.CopyTo(o.BillingAddress, EFConnString(settings.SourceConnectionString()));
            }
            o.Bvin = old.Bvin ?? string.Empty;
            o.CustomProperties = TranslateOldProperties(old.CustomProperties);
            o.FraudScore = old.FraudScore;
            o.Id = old.id;
            o.Instructions = old.Instructions;
            o.IsPlaced = old.IsPlaced == 1;
            o.LastUpdatedUtc = old.LastUpdated;
            o.OrderNumber = old.OrderNumber ?? string.Empty;
            if (old.OrderDiscounts != 0)
            {
                o.OrderDiscountDetails.Add(new DiscountDetailDTO() { Amount = -1 * old.OrderDiscounts, Description = "BV 5 Order Discounts", Id = new Guid() });
            }
            o.PaymentStatus = OrderPaymentStatusDTO.Unknown;
            switch (old.PaymentStatus)
            {
                case 0:
                    o.PaymentStatus = OrderPaymentStatusDTO.Unknown;
                    break;
                case 1:
                    o.PaymentStatus = OrderPaymentStatusDTO.Unpaid;
                    break;
                case 2:
                    o.PaymentStatus = OrderPaymentStatusDTO.PartiallyPaid;
                    break;
                case 3:
                    o.PaymentStatus = OrderPaymentStatusDTO.Paid;
                    break;
                case 4:
                    o.PaymentStatus = OrderPaymentStatusDTO.Overpaid;
                    break;
            }
            BV5Address oldShipping = new BV5Address();
            oldShipping.FromXmlString(old.ShippingAddress);
            if (oldShipping != null) oldShipping.CopyTo(o.ShippingAddress, EFConnString(settings.SourceConnectionString()));
            o.ShippingMethodDisplayName = old.ShippingMethodDisplayName;
            o.ShippingMethodId = old.ShippingMethodId;
            o.ShippingProviderId = old.ShippingProviderId;
            o.ShippingProviderServiceCode = old.ShippingProviderServiceCode;
            o.ShippingStatus = OrderShippingStatusDTO.Unknown;
            switch (old.ShippingStatus)
            {
                case 0:
                    o.ShippingStatus = OrderShippingStatusDTO.Unknown;
                    break;
                case 1:
                    o.ShippingStatus = OrderShippingStatusDTO.Unshipped;
                    break;
                case 2:
                    o.ShippingStatus = OrderShippingStatusDTO.PartiallyShipped;
                    break;
                case 3:
                    o.ShippingStatus = OrderShippingStatusDTO.FullyShipped;
                    break;
                case 4:
                    o.ShippingStatus = OrderShippingStatusDTO.NonShipping;
                    break;
            }
            o.StatusCode = old.StatusCode ?? string.Empty;
            o.StatusName = old.StatusName;
            o.ThirdPartyOrderId = old.ThirdPartyOrderId;
            o.TimeOfOrderUtc = old.TimeOfOrder;
            o.TotalHandling = old.HandlingTotal;
            o.TotalShippingBeforeDiscounts = old.ShippingTotal + old.ShippingDiscounts;
            o.ShippingDiscountDetails.Add(new DiscountDetailDTO() { Amount = -1 * old.ShippingDiscounts, Description = "BV5 Shipping Discount", Id = new Guid() });
            o.TotalTax = old.TaxTotal;
            o.TotalTax2 = old.TaxTotal2;
            o.UserEmail = old.UserEmail;
            o.UserID = old.UserId;

            wl(" - Coupons for Order " + old.OrderNumber);
            o.Coupons = TranslateCoupons(o.Bvin);

            wl(" - Items For order " + old.OrderNumber);
            o.Items = TranslateItems(o.Bvin);
            LineItemHelper.SplitTaxesAcrossItems(old.TaxTotal2 + old.TaxTotal, old.SubTotal, o.Items);

            wl(" - Notes For order " + old.OrderNumber);
            o.Notes = TranslateNotes(o.Bvin);

            wl(" - Packages For order " + old.OrderNumber);
            o.Packages = TranslatePackages(o.Bvin);
        }
示例#5
0
        public void FromDTO(OrderDTO dto)
        {
            if (dto == null) return;

            this.AffiliateID = dto.AffiliateID ?? string.Empty;
            this.BillingAddress.FromDto(dto.BillingAddress);
            this.bvin = dto.Bvin ?? string.Empty;
            this.Coupons.Clear();
            if (dto.Coupons != null)
            {
                foreach (OrderCouponDTO c in dto.Coupons)
                {
                    OrderCoupon cp = new OrderCoupon();
                    cp.FromDto(c);
                    this.Coupons.Add(cp);
                }
            }
            this.CustomProperties.Clear();
            if (dto.CustomProperties != null)
            {
                foreach (CustomPropertyDTO prop in dto.CustomProperties)
                {
                    CustomProperty p = new CustomProperty();
                    p.FromDto(prop);
                    this.CustomProperties.Add(p);
                }
            }
            this.FraudScore = dto.FraudScore;
            this.Id = dto.Id;
            this.Instructions = dto.Instructions ?? string.Empty;
            this.IsPlaced = dto.IsPlaced;
            this.Items.Clear();
            if (dto.Items != null)
            {
                foreach (LineItemDTO li in dto.Items)
                {
                    LineItem l = new LineItem();
                    l.FromDto(li);
                    this.Items.Add(l);
                }
            }
            this.LastUpdatedUtc = dto.LastUpdatedUtc;
            this.Notes.Clear();
            if (dto.Notes != null)
            {
                foreach (OrderNoteDTO n in dto.Notes)
                {
                    OrderNote nn = new OrderNote();
                    nn.FromDto(n);
                    this.Notes.Add(nn);
                }
            }
            this.OrderDiscountDetails.Clear();
            if (dto.OrderDiscountDetails != null)
            {
                foreach (DiscountDetailDTO d in dto.OrderDiscountDetails)
                {
                    Marketing.DiscountDetail m = new Marketing.DiscountDetail();
                    m.FromDto(d);
                    this.OrderDiscountDetails.Add(m);
                }
            }
            this.OrderNumber = dto.OrderNumber ?? string.Empty;
            this.Packages.Clear();
            if (dto.Packages != null)
            {
                foreach (OrderPackageDTO pak in dto.Packages)
                {
                    OrderPackage pak2 = new OrderPackage();
                    pak2.FromDto(pak);
                    this.Packages.Add(pak2);
                }
            }
            this.PaymentStatus = (OrderPaymentStatus)((int)dto.PaymentStatus);
            this.ShippingAddress.FromDto(dto.ShippingAddress);
            this.ShippingDiscountDetails.Clear();
            if (dto.ShippingDiscountDetails != null)
            {
                foreach (DiscountDetailDTO sd in dto.ShippingDiscountDetails)
                {
                    Marketing.DiscountDetail sdd = new Marketing.DiscountDetail();
                    sdd.FromDto(sd);
                    this.ShippingDiscountDetails.Add(sdd);
                }
            }
            this.ShippingMethodDisplayName = dto.ShippingMethodDisplayName ?? string.Empty;
            this.ShippingMethodId = dto.ShippingMethodId ?? string.Empty;
            this.ShippingProviderId = dto.ShippingProviderId ?? string.Empty;
            this.ShippingProviderServiceCode = dto.ShippingProviderServiceCode ?? string.Empty;
            this.ShippingStatus = (OrderShippingStatus)((int)dto.ShippingStatus);
            this.StatusCode = dto.StatusCode ?? string.Empty;
            this.StatusName = dto.StatusName ?? string.Empty;
            this.StoreId = dto.StoreId;
            this.ThirdPartyOrderId = dto.ThirdPartyOrderId ?? string.Empty;
            this.TimeOfOrderUtc = dto.TimeOfOrderUtc;
            this.TotalHandling = dto.TotalHandling;
            this.TotalShippingBeforeDiscounts = dto.TotalShippingBeforeDiscounts;
            this.TotalTax = dto.TotalTax;
            this.TotalTax2 = dto.TotalTax2;
            this.UserEmail = dto.UserEmail ?? string.Empty;
            this.UserID = dto.UserID ?? string.Empty;
        }
示例#6
0
        // DTO
        public OrderDTO ToDto()
        {
            OrderDTO dto = new OrderDTO();

            dto.AffiliateID = this.AffiliateID ?? string.Empty;
            dto.BillingAddress = this.BillingAddress.ToDto();
            dto.Bvin = this.bvin ?? string.Empty;
            dto.Coupons = new List<OrderCouponDTO>();
            foreach (OrderCoupon c in this.Coupons)
            {
                dto.Coupons.Add(c.ToDto());
            }
            dto.CustomProperties = new List<CustomPropertyDTO>();
            foreach (CustomProperty prop in this.CustomProperties)
            {
                dto.CustomProperties.Add(prop.ToDto());
            }
            dto.FraudScore = this.FraudScore;
            dto.Id = this.Id;
            dto.Instructions = this.Instructions ?? string.Empty;
            dto.IsPlaced = this.IsPlaced;
            dto.Items = new List<LineItemDTO>();
            foreach (LineItem li in this.Items)
            {
                dto.Items.Add(li.ToDto());
            }
            dto.LastUpdatedUtc = this.LastUpdatedUtc;
            dto.Notes = new List<OrderNoteDTO>();
            foreach (OrderNote n in this.Notes)
            {
                dto.Notes.Add(n.ToDto());
            }
            dto.OrderDiscountDetails = new List<DiscountDetailDTO>();
            foreach (Marketing.DiscountDetail d in this.OrderDiscountDetails)
            {
                dto.OrderDiscountDetails.Add(d.ToDto());
            }
            dto.OrderNumber = this.OrderNumber ?? string.Empty;
            dto.Packages = new List<OrderPackageDTO>();
            foreach (OrderPackage pak in this.Packages)
            {
                dto.Packages.Add(pak.ToDto());
            }
            dto.PaymentStatus = (OrderPaymentStatusDTO)((int)this.PaymentStatus);
            dto.ShippingAddress = this.ShippingAddress.ToDto();
            dto.ShippingDiscountDetails = new List<DiscountDetailDTO>();
            foreach (Marketing.DiscountDetail sd in this.ShippingDiscountDetails)
            {
                dto.ShippingDiscountDetails.Add(sd.ToDto());
            }
            dto.ShippingMethodDisplayName = this.ShippingMethodDisplayName ?? string.Empty;
            dto.ShippingMethodId = this.ShippingMethodId ?? string.Empty;
            dto.ShippingProviderId = this.ShippingProviderId ?? string.Empty;
            dto.ShippingProviderServiceCode = this.ShippingProviderServiceCode ?? string.Empty;
            dto.ShippingStatus = (OrderShippingStatusDTO)((int)this.ShippingStatus);
            dto.StatusCode = this.StatusCode ?? string.Empty;
            dto.StatusName = this.StatusName ?? string.Empty;
            dto.StoreId = this.StoreId;
            dto.ThirdPartyOrderId = this.ThirdPartyOrderId ?? string.Empty;
            dto.TimeOfOrderUtc = this.TimeOfOrderUtc;
            dto.TotalHandling = this.TotalHandling;
            dto.TotalShippingBeforeDiscounts = this.TotalShippingBeforeDiscounts;
            dto.TotalTax = this.TotalTax;
            dto.TotalTax2 = this.TotalTax2;
            dto.UserEmail = this.UserEmail ?? string.Empty;
            dto.UserID = this.UserID ?? string.Empty;

            return dto;
        }