예제 #1
0
        private void ImportProductModifiers()
        {
            Header("Importing Modifiers");

            foreach (data.bvc_ProductModifier old in oldDatabase.bvc_ProductModifier)
            {
                OptionDTO o = new OptionDTO();
                string fullName = old.Name;
                if (old.Displayname.Trim().Length > 0) fullName = old.Displayname;

                o.Settings = new List<OptionSettingDTO>();
                o.Items = new List<OptionItemDTO>();
                o.Bvin = old.bvin;
                o.IsShared = old.Shared;
                o.IsVariant = false; // Modifiers can't be variants
                o.NameIsHidden = false;
                if (old.Required) o.Settings.Add(new OptionSettingDTO() { Key = "required", Value = "1" });

                switch (old.Type.Trim().ToLowerInvariant())
                {
                    case "radio button list":
                    case "image radio button list":
                        o.OptionType = OptionTypesDTO.RadioButtonList;
                        break;
                    default: // Drop Down List
                        o.OptionType = OptionTypesDTO.DropDownList;
                        break;
                }
                o.Name = fullName;
                wl("Modifier: " + fullName);

                // Load Items for Option Here
                o.Items = LoadOptionItemsModifier(o.Bvin);

                Api bv6proxy = GetBV6Proxy();
                var res = bv6proxy.ProductOptionsCreate(o);
                if (res != null)
                {
                    if (res.Errors.Count() > 0)
                    {
                        DumpErrors(res.Errors);
                        wl("FAILED");
                    }
                    else
                    {
                        wl("SUCCESS");
                    }
                }
            }
        }
예제 #2
0
        // Choices, Modifiers, Inputs               
        private void ImportProductChoices()
        {
            Header("Importing Shared Choices");

            data.bvc2004Entities oldDatabase = GetOldDatabase();
            foreach (data.bvc_ProductChoices old in oldDatabase.bvc_ProductChoices)
            {

                OptionDTO o = new OptionDTO();
                string fullName = old.PropertyName;
                if (old.DisplayName.Trim().Length > 0) fullName = old.DisplayName;

                o.Settings = new List<OptionSettingDTO>();
                o.Items = new List<OptionItemDTO>();
                o.Bvin = old.ID.ToString();
                o.IsShared = (old.Shared == 1);
                o.IsVariant = false; // Choices are NOT variants in BV6 unless explicitly set
                o.NameIsHidden = false;

                switch (old.TypeCode)
                {
                    case 9: //ProductChoiceType.HtmlArea    
                        o.OptionType = OptionTypesDTO.Html;
                        o.Settings.Add(new OptionSettingDTO() { Key = "html", Value = old.Html });
                        break;
                    case 2: //ProductChoiceType.MultipleChoiceField
                        o.OptionType = OptionTypesDTO.DropDownList;
                        break;
                    case 8: // ProductChoiceType.RadioButtonList
                        o.OptionType = OptionTypesDTO.RadioButtonList;
                        break;
                    case 1: // TextField
                        o.OptionType = OptionTypesDTO.TextInput;
                        o.Settings.Add(new OptionSettingDTO() { Key = "rows", Value = old.TextRows.ToString() });
                        o.Settings.Add(new OptionSettingDTO() { Key = "cols", Value = old.TextColumns.ToString() });
                        o.Settings.Add(new OptionSettingDTO() { Key = "required", Value = (old.Html == "REQUIRED" ? "1" : "0") });
                        o.Settings.Add(new OptionSettingDTO() { Key = "wraptext", Value = (old.TextWrap == 1 ? "1" : "0") });
                        o.Settings.Add(new OptionSettingDTO() { Key = "maxlength", Value = "255" });
                        break;
                    case 21: // AccessoryCheckBox
                        continue;
                    case 23: // AccessoryDropdownList
                        continue;
                    case 22: // AccessoryRadioButtonList                            
                        continue;
                }
                o.Name = fullName;
                wl("Choice: " + fullName);

                // Load Items for Option Here
                o.Items = LoadOptionItemsChoice(old.ID);

                Api bv6proxy = GetBV6Proxy();
                var res = bv6proxy.ProductOptionsCreate(o);
                if (res != null)
                {
                    if (res.Errors.Count() > 0)
                    {
                        DumpErrors(res.Errors);
                        wl("FAILED");
                    }
                    else
                    {
                        wl("SUCCESS");
                    }
                }
            }
        }
예제 #3
0
        // Choices, Modifiers, Inputs
        private void ImportProductInputs()
        {
            Header("Importing Product Inputs");

            foreach (data.bvc_ProductInputs oldInput in oldDatabase.bvc_ProductInputs)
            {

                OptionDTO input = new OptionDTO();
                string fullName = oldInput.InputName;
                if (oldInput.InputDisplayName.Trim().Length > 0) fullName = oldInput.InputDisplayName;

                input.Settings = new List<OptionSettingDTO>();
                input.Items = new List<OptionItemDTO>();
                input.Bvin = oldInput.bvin;
                input.IsShared = oldInput.SharedInput;
                input.IsVariant = false; // Inputs can't be variants

                input.NameIsHidden = false;
                switch (oldInput.InputType.Trim().ToLowerInvariant())
                {
                    case "html area":
                        input.OptionType = OptionTypesDTO.Html;
                        BV5OptionHtmlSettings htmlSettings = GetOptionSettingsHtml(input.Bvin);
                        input.Settings.Add(new OptionSettingDTO() { Key = "html", Value = htmlSettings.HtmlData });
                        break;
                    default: // Text Input
                        input.OptionType = OptionTypesDTO.TextInput;
                        BV5OptionTextSettings textSettings = GetOptionSettingsText(input.Bvin);
                        input.Settings.Add(new OptionSettingDTO() { Key = "rows", Value = textSettings.Rows });
                        input.Settings.Add(new OptionSettingDTO() { Key = "cols", Value = textSettings.Columns });
                        input.Settings.Add(new OptionSettingDTO() { Key = "required", Value = textSettings.Required });
                        input.Settings.Add(new OptionSettingDTO() { Key = "wraptext", Value = textSettings.WrapText });
                        input.Settings.Add(new OptionSettingDTO() { Key = "maxlength", Value = "255" });
                        if (textSettings.DisplayName.Trim().Length > 0) fullName = textSettings.DisplayName;
                        break;
                }
                input.Name = fullName;
                wl("Input: " + fullName);

                Api bv6proxy = GetBV6Proxy();
                var res = bv6proxy.ProductOptionsCreate(input);
                if (res != null)
                {
                    if (res.Errors.Count() > 0)
                    {
                        DumpErrors(res.Errors);
                        wl("FAILED");
                    }
                    else
                    {
                        wl("SUCCESS");
                    }
                }
            }
        }
예제 #4
0
        private void ImportProductChoices()
        {
            Header("Importing Shared Choices");

            foreach (data.bvc_ProductChoices old in oldDatabase.bvc_ProductChoices)
            {
                OptionDTO o = new OptionDTO();
                string fullName = old.ChoiceName;
                if (old.ChoiceDisplayName.Trim().Length > 0) fullName = old.ChoiceDisplayName;

                o.Settings = new List<OptionSettingDTO>();
                o.Items = new List<OptionItemDTO>();
                o.Bvin = old.bvin;
                o.IsShared = old.SharedChoice;
                o.IsVariant = true; // Choices are always variants in BV6
                o.NameIsHidden = false;

                switch (old.ChoiceType.Trim().ToLowerInvariant())
                {
                    case "radio button list":
                    case "image radio button list":
                        o.OptionType = OptionTypesDTO.RadioButtonList;
                        break;
                    default: // Drop Down List
                        o.OptionType = OptionTypesDTO.DropDownList;
                        break;
                }
                o.Name = fullName;
                wl("Choice: " + fullName);

                // Load Items for Option Here
                o.Items = LoadOptionItemsChoice(o.Bvin);

                Api bv6proxy = GetBV6Proxy();
                var res = bv6proxy.ProductOptionsCreate(o);
                if (res != null)
                {
                    if (res.Errors.Count() > 0)
                    {
                        DumpErrors(res.Errors);
                        wl("FAILED");
                    }
                    else
                    {
                        wl("SUCCESS");
                    }
                }
            }
        }
예제 #5
0
        public void FromDto(OptionDTO dto)
        {
            if (dto == null) return;

            this.Bvin = dto.Bvin ?? string.Empty;
            this.IsShared = dto.IsShared;
            this.IsVariant = dto.IsVariant;
            this.Items.Clear();
            this.Name = dto.Name ?? string.Empty;
            this.NameIsHidden = dto.NameIsHidden;                        
            this.StoreId = dto.StoreId;
            
            OptionTypes typeCode = OptionTypes.DropDownList;
            typeCode = (OptionTypes)dto.OptionType;
            this.SetProcessor(typeCode);

            foreach (OptionItemDTO oi in dto.Items)
            {
                OptionItem opt = new OptionItem();
                opt.FromDto(oi);
                this.AddItem(opt);                
            }
            this.Settings = new OptionSettings();
            foreach (OptionSettingDTO set in dto.Settings)
            {
                this.Settings.AddOrUpdate(set.Key, set.Value);
            }           
        }
예제 #6
0
        //DTO
        public OptionDTO ToDto()
        {
            OptionDTO dto = new OptionDTO();

            dto.Bvin = this.Bvin;
            dto.IsShared = this.IsShared;
            dto.IsVariant = this.IsVariant;
            dto.Items = new List<OptionItemDTO>();
            foreach (OptionItem oi in this.Items)
            {
                dto.Items.Add(oi.ToDto());
            }
            dto.Name = this.Name;
            dto.NameIsHidden = this.NameIsHidden;
            dto.OptionType = (OptionTypesDTO)((int)this.OptionType);
            dto.Settings = new List<OptionSettingDTO>();
            foreach (var set in this.Settings)
            {
                OptionSettingDTO setdto = new OptionSettingDTO();
                setdto.Key = set.Key;
                setdto.Value = set.Value;
                dto.Settings.Add(setdto);
            }           
            dto.StoreId = this.StoreId;
            
            return dto;
        }
예제 #7
0
 public ApiResponse<OptionDTO> ProductOptionsUpdate(OptionDTO item)
 {
     ApiResponse<OptionDTO> result = new ApiResponse<OptionDTO>();
     result = RestHelper.PostRequest<ApiResponse<OptionDTO>>(this.fullApiUri + "productoptions/" + Enc(item.Bvin) + "?key=" + Enc(key), MerchantTribe.Web.Json.ObjectToJson(item));
     return result;
 }