private AddressInfo GetBillingInfo(Sitecore.Security.UserProfile profile) { /* TODO: Change to your extended address type if you have extended the address domain model. */ AddressInfo billingInfo = new AddressInfo(); billingInfo.Address = profile.GetCustomProperty("Billing Address"); billingInfo.Address2 = profile.GetCustomProperty("Billing Address 2"); billingInfo.City = profile.GetCustomProperty("Billing Address City"); var countryCode = profile.GetCustomProperty("Billing Address Country Code"); var country = this.countryProvider.GetDefault(); if (!string.IsNullOrWhiteSpace(countryCode)) { country = this.countryProvider.Get(countryCode); } billingInfo.Country = country; billingInfo.Name = profile.GetCustomProperty("Billing Address Name"); billingInfo.Name2 = profile.GetCustomProperty("Billing Address Name 2"); billingInfo.Phone = profile.GetCustomProperty("Billing Address Phone"); billingInfo.State = profile.GetCustomProperty("Billing Address State"); billingInfo.Zip = profile.GetCustomProperty("Billing Address Zip"); /* TODO: Populate any additional fields you have added to the address domain model. */ billingInfo.IsBillingDefault = true; return(billingInfo); }
private void SetButtonText(LinkButton button) { Sitecore.Security.Accounts.User user = Sitecore.Context.User; Sitecore.Security.UserProfile profile = user.Profile; string favorites = profile.GetCustomProperty("Favorites"); if (favorites.Contains(Sitecore.Context.Item.ID.ToString())) { button.Text = GetDictionaryText("Remove from Favorites"); } else { button.Text = GetDictionaryText("Add to Favorites"); } }
public ActionResult FavoritesNavigation() { List <GenericLink> favs = new List <GenericLink>(); Sitecore.Security.Accounts.User user = Sitecore.Context.User; Sitecore.Security.UserProfile profile = user.Profile; string ItemIds = profile.GetCustomProperty("Favorites"); foreach (string itemId in ItemIds.Split('|')) { Item item = Sitecore.Context.Database.GetItem(itemId); if (item != null) { favs.Add(new GenericLink(item["Menu Title"], LinkManager.GetItemUrl(item), false)); } } return((favs.Count > 0) ? View("TertiaryNavigationPartialFavorites", favs as IEnumerable <GenericLink>) : null); }
public ActionResult AddToFavorites(string itemId) { try { Sitecore.Security.Accounts.User user = Sitecore.Context.User; Sitecore.Security.UserProfile profile = user.Profile; string favorites = profile.GetCustomProperty("Favorites"); // determine if we are adding or removing. // We don't know the text of the button because it is managed in the CMS, so we will see it is already a favorite. if (favorites.Contains(Sitecore.Context.Item.ID.ToString())) { favorites = favorites.Replace(Sitecore.Context.Item.ID.ToString(), String.Empty); favorites = favorites.Replace("||", "|"); // when removing we may leave a double pipe if (favorites == "|") { favorites = String.Empty; } } else // it must be an add { if (favorites == String.Empty) { favorites = Sitecore.Context.Item.ID.ToString(); } else { favorites = favorites + "|" + Sitecore.Context.Item.ID.ToString(); } // Capture the goal AnalyticsHelper.RegisterGoalOnCurrentPage("Add a Favorite", "[Add a Favorite] : \"" + Sitecore.Context.Item.Name + "\""); } profile.SetCustomProperty("Favorites", favorites); profile.Save(); } catch { } return(View("AddToFavorites", IsAddToFavorites)); }
protected void btnAddtoFavs_Click(object sender, EventArgs e) { Sitecore.Security.Accounts.User user = Sitecore.Context.User; Sitecore.Security.UserProfile profile = user.Profile; string favorites = profile.GetCustomProperty("Favorites"); // determine if we are adding or removing. // We don't know the text of the button because it is managed in the CMS, so we will see it is already a favorite. if (favorites.Contains(Sitecore.Context.Item.ID.ToString())) { favorites = favorites.Replace(Sitecore.Context.Item.ID.ToString(), String.Empty); favorites = favorites.Replace("||", "|"); // when removeing we may leave a double pipe if (favorites == "|") { favorites = String.Empty; } } else // it must be an add { if (favorites == String.Empty) { favorites = Sitecore.Context.Item.ID.ToString(); } else { favorites = favorites + "|" + Sitecore.Context.Item.ID.ToString(); } // Capture the goal using our helper method AnalyticsHelper.RegisterGoalOnCurrentPage("Add a Favorite", "[Add a Favorite] : \"" + Sitecore.Context.Item.Name + "\""); //Tracker.CurrentVisit.CurrentPage.Register("Add a Favorite", "[Add a Favorite] : \"" + Sitecore.Context.Item.Name + "\""); } profile.SetCustomProperty("Favorites", favorites); profile.Save(); SetButtonText(sender as LinkButton); }
protected void btnPrint_Click(object sender, EventArgs e) { Item projectItem = Sitecore.Context.Database.GetItem(this.projectPath); Sitecore.Security.Accounts.User user = Sitecore.Context.User; Sitecore.Security.UserProfile profile = user.Profile; if (projectItem != null) { string fileName = string.Format("{0}_{1}", projectItem.Name, DateTime.Now.Ticks.ToString()); PrintOptions printOptions = new PrintOptions { PrintExportType = PrintExportType.Pdf, ResultFileName = fileName, UseHighRes = false }; Database masterBase = Factory.GetDatabase("master"); printOptions.Parameters.Add("articles", profile.GetCustomProperty("Favorites")); PrintManager printManager = new PrintManager(masterBase, Sitecore.Context.Language); string result = printManager.Print(projectItem.ID.ToString(), printOptions); if (!string.IsNullOrEmpty(result) && File.Exists(result)) { var file = new FileInfo(result); Response.ContentType = "application/pdf"; Response.AppendHeader("content-disposition", string.Format("attachment; filename={0}", file.Name)); Response.AppendHeader("Content-Length", file.Length.ToString()); Response.TransmitFile(file.FullName); Response.Flush(); Response.End(); } } }
private void LoadFavorites() { List <Item> items = new List <Item>(); Sitecore.Security.Accounts.User user = Sitecore.Context.User; Sitecore.Security.UserProfile profile = user.Profile; string ItemIds = profile.GetCustomProperty("Favorites"); foreach (string itemId in ItemIds.Split('|')) { Item item = Sitecore.Context.Database.GetItem(itemId); if (item != null) { items.Add(item); } } if (items.Count > 0) { favoritesli.Visible = true; rptFavorites.DataSource = items; rptFavorites.DataBind(); } }