Пример #1
0
        private AffiliateDTO OldToNewAffiliate(data.bvc_Affiliate aff)
        {
            AffiliateDTO affiliate = new AffiliateDTO();

            BVC2004Address oldAddress = new BVC2004Address();
            oldAddress.FromXmlString(aff.Address);

            affiliate.Address = new AddressDTO();
            if (oldAddress != null)
            {
                oldAddress.CopyTo(affiliate.Address, EFConnString(settings.SourceConnectionString()));
            }
            affiliate.CommissionAmount = (decimal)aff.CommissionAmount;
            switch (aff.CommissionType)
            {
                case 0:
                    affiliate.CommissionType = AffiliateCommissionTypeDTO.None;
                    break;
                case 1:
                    affiliate.CommissionType = AffiliateCommissionTypeDTO.PercentageCommission;
                    break;
                case 2:
                    affiliate.CommissionType = AffiliateCommissionTypeDTO.FlatRateCommission;
                    break;
                default:
                    affiliate.CommissionType = AffiliateCommissionTypeDTO.PercentageCommission;
                    break;
            }
            affiliate.CustomThemeName = aff.StyleSheet;
            affiliate.DisplayName = aff.DisplayName;
            affiliate.DriversLicenseNumber = aff.DriversLicenseNumber;
            affiliate.Enabled = true;
            affiliate.Id = -1;
            affiliate.LastUpdatedUtc = DateTime.UtcNow;
            affiliate.Notes = string.Empty;
            affiliate.ReferralDays = aff.ReferralDays;
            affiliate.ReferralId = aff.ID.ToString();
            affiliate.TaxId = aff.TaxID;
            affiliate.WebSiteUrl = aff.WebSiteURL;
            affiliate.Contacts = new List<AffiliateContactDTO>();

            return affiliate;
        }
Пример #2
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);

        }
Пример #3
0
        private void ImportVendors()
        {
            Header("Importing Vendors");

            data.bvc2004Entities oldDatabase = GetOldDatabase();
            foreach (data.bvc_Vendor old in oldDatabase.bvc_Vendor)
            {
                wl("Item: " + old.DisplayName);

                VendorManufacturerDTO vm = new VendorManufacturerDTO();

                BVC2004Address oldAddr = new BVC2004Address();
                oldAddr.FromXmlString(old.Address);                
                if (oldAddr != null)
                {
                    oldAddr.CopyTo(vm.Address, EFConnString(settings.SourceConnectionString()));
                }
                vm.Bvin = old.ID.ToString();                
                vm.ContactType = VendorManufacturerTypeDTO.Vendor;
                vm.DisplayName = old.DisplayName;
                vm.DropShipEmailTemplateId = string.Empty;
                vm.EmailAddress = old.EmailAddress;
                vm.LastUpdated = DateTime.UtcNow;

                Api bv6proxy = GetBV6Proxy();
                var res = bv6proxy.VendorCreate(vm);
                if (res != null)
                {
                    if (res.Errors.Count() > 0)
                    {
                        DumpErrors(res.Errors);
                        wl("FAILED");
                    }
                    else
                    {
                        wl("SUCCESS");
                    }
                }
            }
        }