protected void Page_Load(object sender, EventArgs e) { if (!login()) { Response.Redirect("MainPage.aspx"); } if (!IsPostBack) { marcas = marcaBusiness.listar(); BrandSelector.DataSource = marcas; BrandSelector.DataBind(); loadCat(); modificacion = ismod(); if (!modificacion) { generateCode(); } } }
public IList <GoogleProductFeedEntry> GetEntries(string market, string language, string currency) { IMarket selectedMarket; if (string.IsNullOrWhiteSpace(market)) { selectedMarket = CurrentMarket.Service.GetCurrentMarket(); } else { selectedMarket = MarketService.Service.GetAllMarkets()?.FirstOrDefault(m => m.MarketId.Value.Equals(market, StringComparison.InvariantCultureIgnoreCase)); } if (selectedMarket == null) { throw new ArgumentException("Selected market could not be found (or default could not be found if no market specified)"); } market = selectedMarket.MarketId.Value; // ensure correct casing if (string.IsNullOrWhiteSpace(language)) { language = selectedMarket.DefaultLanguage.Name; } if (string.IsNullOrWhiteSpace(currency)) { currency = selectedMarket.DefaultCurrency.CurrencyCode; } currency = currency.ToUpper(); var entries = new Dictionary <string, GoogleProductFeedEntry>(); var client = VulcanHandler.Service.GetClient(new System.Globalization.CultureInfo(language)); if (client != null) { var hits = client.SearchContent <T>(Query, false, new[] { ReferenceConverter.Service.GetRootLink() })?.GetHitContents <IContent>(); if (hits != null && hits.Any()) { foreach (var hit in hits) { var product = hit.Value as T; if (!entries.ContainsKey(product.Code)) { var price = hit.Key.Source.GetPrice(market, currency); if (price != 0) { var image = AssetUrlResolver.Service.GetAssetUrl(product); if (!string.IsNullOrWhiteSpace(image)) { var description = DescriptionSelector == null ? product.DisplayName : DescriptionSelector.Invoke(product); if (string.IsNullOrWhiteSpace(description)) { description = product.DisplayName; // double-check in case it's empty } entries.Add(product.Code, new GoogleProductFeedEntry() { Id = product.Code?.Replace('\t', ' '), Title = product.DisplayName?.Replace('\t', ' '), Description = description?.Replace('\t', ' '), Availability = AvailabilitySelector == null ? "in stock" : AvailabilitySelector.Invoke(product)?.Replace('\t', ' '), Adult = AdultSelector == null ? "no" : AdultSelector.Invoke(product)?.Replace('\t', ' '), Brand = BrandSelector == null ? null : BrandSelector.Invoke(product)?.Replace('\t', ' '), Condition = ConditionSelector == null ? "new" : ConditionSelector.Invoke(product)?.Replace('\t', ' '), GoogleProductCategory = GoogleProductCategorySelector == null ? null : GoogleProductCategorySelector.Invoke(product)?.Replace('\t', ' '), GTIN = GTINSelector == null ? null : GTINSelector.Invoke(product)?.Replace('\t', ' '), MPN = MPNSelector == null ? null : MPNSelector.Invoke(product)?.Replace('\t', ' '), Shipping = ShippingSelector == null ? null : ShippingSelector.Invoke(product)?.Replace('\t', ' '), Tax = TaxSelector == null ? null : TaxSelector.Invoke(product)?.Replace('\t', ' '), ImageLink = FullUrl(image), Link = FullUrl(UrlResolver.Current.GetUrl(product)), Price = price.ToString("F2", CultureInfo.InvariantCulture) + " " + currency.ToUpper() }); } } } } } } return(entries.Values.Cast <GoogleProductFeedEntry>().ToList()); }