Ejemplo n.º 1
0
        /// <summary>
        /// Uninstall plugin
        /// </summary>
        public override void Uninstall()
        {
            _services.Localization.DeleteLocaleStringResources(PluginDescriptor.ResourceRootKey);

            // Delete existing export profiles.
            var profiles = _exportProfileService.GetExportProfilesBySystemName(GmcXmlExportProvider.SystemName);

            profiles.Each(x => _exportProfileService.DeleteExportProfile(x, true));

            var migrator = new DbMigrator(new Configuration());

            migrator.Update(DbMigrator.InitialDatabase);

            base.Uninstall();
        }
		public ActionResult ProductEditTab(int productId)
		{
			var culture = CultureInfo.InvariantCulture;
			var model = new GoogleProductModel { ProductId = productId };
			var entity = _googleFeedService.GetGoogleProductRecord(productId);
			string notSpecified = T("Common.Unspecified");

			if (entity != null)
			{
				model.Taxonomy = entity.Taxonomy;
				model.Gender = entity.Gender;
				model.AgeGroup = entity.AgeGroup;
				model.IsAdult = entity.IsAdult;
				model.Color = entity.Color;
				model.Size = entity.Size;
				model.Material = entity.Material;
				model.Pattern = entity.Pattern;
				model.Export2 = entity.Export;
				model.Multipack2 = entity.Multipack;
				model.IsBundle = entity.IsBundle;
				model.EnergyEfficiencyClass = entity.EnergyEfficiencyClass;
				model.CustomLabel0 = entity.CustomLabel0;
				model.CustomLabel1 = entity.CustomLabel1;
				model.CustomLabel2 = entity.CustomLabel2;
				model.CustomLabel3 = entity.CustomLabel3;
				model.CustomLabel4 = entity.CustomLabel4;
			}
			else
			{
				model.Export2 = true;
			}

			ViewBag.DefaultCategory = "";
			ViewBag.DefaultColor = "";
			ViewBag.DefaultSize = "";
			ViewBag.DefaultMaterial = "";
			ViewBag.DefaultPattern = "";
			ViewBag.DefaultGender = notSpecified;
			ViewBag.DefaultAgeGroup = notSpecified;
			ViewBag.DefaultIsAdult = "";
			ViewBag.DefaultMultipack2 = "";
			ViewBag.DefaultIsBundle = "";
			ViewBag.DefaultEnergyEfficiencyClass = notSpecified;
			ViewBag.DefaultCustomLabel = "";

			// we do not have export profile context here, so we simply use the first profile
			var profile = _exportService.GetExportProfilesBySystemName(GmcXmlExportProvider.SystemName).FirstOrDefault();
			if (profile != null)
			{
				var config = XmlHelper.Deserialize(profile.ProviderConfigData, typeof(ProfileConfigurationModel)) as ProfileConfigurationModel;
				if (config != null)
				{
					ViewBag.DefaultCategory = config.DefaultGoogleCategory;
					ViewBag.DefaultColor = config.Color;
					ViewBag.DefaultSize = config.Size;
					ViewBag.DefaultMaterial = config.Material;
					ViewBag.DefaultPattern = config.Pattern;

					if (config.Gender.HasValue() && config.Gender != GmcXmlExportProvider.Unspecified)
					{
						ViewBag.DefaultGender = T("Plugins.Feed.Froogle.Gender" + culture.TextInfo.ToTitleCase(config.Gender));
					}

					if (config.AgeGroup.HasValue() && config.AgeGroup != GmcXmlExportProvider.Unspecified)
					{
						ViewBag.DefaultAgeGroup = T("Plugins.Feed.Froogle.AgeGroup" + culture.TextInfo.ToTitleCase(config.AgeGroup));
					}
				}
			}		

			ViewBag.AvailableGenders = new List<SelectListItem>
			{ 
				new SelectListItem { Value = "male", Text = T("Plugins.Feed.Froogle.GenderMale") },
				new SelectListItem { Value = "female", Text = T("Plugins.Feed.Froogle.GenderFemale") },
				new SelectListItem { Value = "unisex", Text = T("Plugins.Feed.Froogle.GenderUnisex") }
			};

			ViewBag.AvailableAgeGroups = new List<SelectListItem>
			{ 
				new SelectListItem { Value = "adult", Text = T("Plugins.Feed.Froogle.AgeGroupAdult") },
				new SelectListItem { Value = "kids", Text = T("Plugins.Feed.Froogle.AgeGroupKids") },
			};

			ViewBag.AvailableEnergyEfficiencyClasses = T("Plugins.Feed.Froogle.EnergyEfficiencyClasses").Text
				.SplitSafe(",")
				.Select(x => new SelectListItem { Value = x, Text = x })
				.ToList();

			var result = PartialView(model);
			result.ViewData.TemplateInfo = new TemplateInfo { HtmlFieldPrefix = "CustomProperties[GMC]" };
			return result;
		}