public void AbsoluteContent() { string expectedUrl = String.Format("http://localhost/app/content/abc.txt"); string generatedUrl = _helper.AbsoluteContent("~/content/abc.txt"); Assert.AreEqual(expectedUrl, generatedUrl); }
private void SendEmailToNineStar(Donation donation) { var template = Dictionary.DonationReceivedEmail; var title = "We have received a donation!"; _mailer.SendEmail(title, TemplateProcessor.PopulateTemplate(template, new { Title = title, donation.Customer, donation.CustomerEmail, Amount = donation.DonationAmount, donation.Currency, LinkToSummary = _urlHelper.AbsoluteAction("Index", "Donations"), Company = _config.CompanyName, ImageUrl = _urlHelper.AbsoluteContent(_config.CompanyLogoUrl) }), _config.SupportEmailAddress, _config.CompanyName, _config.SupportEmailAddress, _config.CompanyName); }
private static string PreviewContent_(UrlHelper urlHelper, DesignerKey designerKey, string reference, string variant, bool absolute) { Require.NotNull(urlHelper, "urlHelper"); var path = "~/" + designerKey.ToString() + "/vignette-" + reference + "-" + variant + ".jpg"; return(absolute ? urlHelper.AbsoluteContent(path) : urlHelper.Content(path)); }
private void SendEmailToVibrantHealth(UserMembership userMembership, PromoCode promoCode) { var template = Dictionary.MembershipCreatedEmail; var title = "We have received a new subscription!"; _mailer.SendEmail(title, TemplateProcessor.PopulateTemplate(template, new { Title = title, Customer = userMembership.User.FullName, CustomerEmail = userMembership.User.EmailAddress, SubscriptionType = userMembership.MembershipOption.SubscriptionTypeNameLocal, TotalPrice = promoCode?.FormattedPrice ?? userMembership.MembershipOption.FormattedPrice, LinkToSummary = _urlHelper.AbsoluteAction("Index", "UserMemberships"), Company = _config.CompanyName, ImageUrl = _urlHelper.AbsoluteContent(_config.CompanyLogoUrl) }), _config.SupportEmailAddress, _config.CompanyName, _config.SupportEmailAddress, _config.CompanyName); }
private void SendEmailToVibrantHealth(Consultation consultation, Contact contact) { var template = Dictionary.ConsultationBookedEmail; var title = "We have received a consultation booking!"; _mailer.SendEmail(title, TemplateProcessor.PopulateTemplate(template, new { Title = title, ContactName = contact.FullName, CustomerEmail = contact.EmailAddress, contact.PhoneNumber, Duration = consultation.DurationDescription, Price = consultation.FormattedPrice, Company = _config.CompanyName, ImageUrl = _urlHelper.AbsoluteContent(_config.CompanyLogoUrl) }), _config.SupportEmailAddress, _config.CompanyName, _config.SupportEmailAddress, _config.CompanyName); }
public IEnumerable <SitemapUrl> GetSitemapUrls(UrlHelper urlHelper) { var pages = pageService.GetRecords(x => x.RefId == null && x.IsEnabled); return(pages.Select(page => new SitemapUrl(page.Title, urlHelper.AbsoluteContent("~/" + page.Slug)) { ChangeFrequency = ChangeFrequency.Weekly, Priority = 0.8f })); }
public void SendPromoCode(EmailPromoCodeViewModel model) { var template = Dictionary.PromoCodeEmail; var title = Dictionary.PromoCodeEmailTitle; var contact = _contactService.GetOrCreateContact("", model.Name, model.EmailAddress); _mailer.SendEmail(title, TemplateProcessor.PopulateTemplate(template, new { Title = title, model.FirstName, model.EmailAddress, ImageUrl = _urlHelper.AbsoluteContent(_config.CompanyLogoUrl), PrivacyPolicyLink = _urlHelper.AbsoluteAction("PrivacyPolicy", "Home"), UnsubscribeLink = _urlHelper.AbsoluteAction("Unsubscribe", "Account", new { code = contact.Name }), PromoLink = _urlHelper.AbsoluteAction("Register", "Account", new { promoCode = model.PromoCode.Code }), PromoDetails = model.PromoCode.Details, DateTime.Now.Year }), model.EmailAddress, model.Name, _config.SupportEmailAddress, _config.CompanyName); model.PromoCode.SentOn = DateTime.Now; _promoCodesRepository.Update(model.PromoCode); }
public void CreateDonation(Donation donation) { try { _donationRepository.Create(donation); _mailer.SendEmail("New Donation", TemplateProcessor.PopulateTemplate(Globalisation.Dictionary.DonationReceivedEmail, new { Title = "We have received a donation!", donation.Customer, donation.CustomerEmail, Amount = donation.DonationAmount, donation.Currency, LinkToSummary = _urlHelper.AsboluteAction("Index", "Donations"), Company = _config.CompanyName, ImageUrl = _urlHelper.AbsoluteContent(_config.CompanyLogoUrl) }), _config.SupportEmailAddress, _config.CompanyName, _config.SupportEmailAddress, _config.CompanyName); } catch (Exception ex) { _logger.Error($"DonationService => CreateDonation => {ex.Message}"); } }
public override void Append(TextPage webpage, XElement urlset, XDocument xmlDocument) { var publishOn = webpage.PublishOn; if (!publishOn.HasValue) { return; } var content = webpage.PublishOn.Value.SitemapDateString(); var urlNode = new XElement(SitemapService.RootNamespace + "url", new XElement(SitemapService.RootNamespace + "loc", webpage.AbsoluteUrl), new XElement(SitemapService.RootNamespace + "lastmod", content) ); if (!string.IsNullOrWhiteSpace(webpage.FeatureImage)) { urlNode.Add(new XElement(SitemapService.ImageNameSpace + "image", new XElement(SitemapService.ImageNameSpace + "loc", _urlHelper.AbsoluteContent(webpage.FeatureImage)))); } urlset.Add(urlNode); }
/// <summary> /// Gets the Open Search XML for the current site. You can customize the contents of this XML here. See /// http://www.hanselman.com/blog/CommentView.aspx?guid=50cc95b1-c043-451f-9bc2-696dc564766d /// http://www.opensearch.org /// </summary> /// <returns>The Open Search XML for the current site.</returns> public string GetOpenSearchXml() { // Short name must be less than or equal to 16 characters. var shortName = "Search"; var description = "Search the ASP.NET MVC Site"; // The link to the search page with the query string set to 'searchTerms' which gets replaced with a user // defined query. var searchUrl = _urlHelper.AbsoluteRouteUrl( "", new { query = "{searchTerms}" }); // The link to the page with the search form on it. The home page has the search form on it. var searchFormUrl = _urlHelper.AbsoluteRouteUrl(HomeControllerRoute.GetSearch); // The link to the favicon.ico file for the site. var favicon16Url = _urlHelper.AbsoluteContent("~/content/icons/favicon.ico"); // The link to the favicon.png file for the site. var favicon32Url = _urlHelper.AbsoluteContent("~/content/icons/favicon-32x32.png"); // The link to the favicon.png file for the site. var favicon96Url = _urlHelper.AbsoluteContent("~/content/icons/favicon-96x96.png"); XNamespace ns = "http://a9.com/-/spec/opensearch/1.1"; var document = new XDocument( new XElement( ns + "OpenSearchDescription", new XElement(ns + "ShortName", shortName), new XElement(ns + "Description", description), new XElement( ns + "Url", new XAttribute("type", "text/html"), new XAttribute("method", "get"), new XAttribute("template", searchUrl)), // Search results can also be returned as RSS. Here, our start index is zero for the first result. // new XElement(ns + "Url", // new XAttribute("type", "application/rss+xml"), // new XAttribute("indexOffset", "0"), // new XAttribute("rel", "results"), // new XAttribute("template", "http://example.com/?q={searchTerms}&start={startIndex?}&format=rss")), // Search suggestions can also be returned as JSON. // new XElement(ns + "Url", // new XAttribute("type", "application/json"), // new XAttribute("indexOffset", "0"), // new XAttribute("rel", "suggestions"), // new XAttribute("template", "http://example.com/suggest?q={searchTerms}")), new XElement( ns + "Image", favicon16Url, new XAttribute("height", "16"), new XAttribute("width", "16"), new XAttribute("type", "image/x-icon")), new XElement( ns + "Image", favicon32Url, new XAttribute("height", "32"), new XAttribute("width", "32"), new XAttribute("type", "image/png")), new XElement( ns + "Image", favicon96Url, new XAttribute("height", "96"), new XAttribute("width", "96"), new XAttribute("type", "image/png")), new XElement(ns + "InputEncoding", "UTF-8"), new XElement(ns + "SearchForm", searchFormUrl))); return(document.ToString(Encoding.UTF8)); }
/// <summary> /// Gets the feed containing meta data about the feed and the feed entries. /// </summary> /// <param name="cancellationToken">A <see cref="CancellationToken" /> signifying if the request is cancelled.</param> /// <returns>A <see cref="SyndicationFeed" />.</returns> public async Task <SyndicationFeed> GetFeed(CancellationToken cancellationToken) { var feed = new SyndicationFeed { // id (Required) - The feed universally unique identifier. Id = FeedId, // title (Required) - Contains a human readable title for the feed. Often the same as the title of the // associated website. This value should not be blank. Title = SyndicationContent.CreatePlaintextContent("ASP.NET MVC Boilerplate"), // items (Required) - The items to add to the feed. Items = await GetItems(cancellationToken).ConfigureAwait(true), // subtitle (Recommended) - Contains a human-readable description or subtitle for the feed. Description = SyndicationContent.CreatePlaintextContent( "This is the ASP.NET MVC Boilerplate feed description."), // updated (Optional) - Indicates the last time the feed was modified in a significant way. LastUpdatedTime = DateTimeOffset.Now, // logo (Optional) - Identifies a larger image which provides visual identification for the feed. // Images should be twice as wide as they are tall. ImageUrl = new Uri(_urlHelper.AbsoluteContent("~/content/icons/atom-logo-96x48.png")), // rights (Optional) - Conveys information about rights, e.g. copyrights, held in and over the feed. Copyright = SyndicationContent.CreatePlaintextContent( string.Format("© {0} - {1}", DateTime.Now.Year, Application.Name)), // lang (Optional) - The language of the feed. Language = "en-GB" // generator (Optional) - Identifies the software used to generate the feed, for debugging and other // purposes. Do not put in anything that identifies the technology you are using. // Generator = "Sample Code", // base (Buggy) - Add the full base URL to the site so that all other links can be relative. This is // great, except some feed readers are buggy with it, INCLUDING FIREFOX!!! // (See https://bugzilla.mozilla.org/show_bug.cgi?id=480600). // BaseUri = new Uri(this.urlHelper.AbsoluteRouteUrl(HomeControllerRoute.GetIndex)) }; // self link (Required) - The URL for the syndication feed. feed.Links.Add(SyndicationLink.CreateSelfLink( new Uri(_urlHelper.AbsoluteRouteUrl(HomeControllerRoute.GetFeed)), ContentType.Atom)); // alternate link (Recommended) - The URL for the web page showing the same data as the syndication feed. feed.Links.Add(SyndicationLink.CreateAlternateLink( new Uri(_urlHelper.AbsoluteRouteUrl(HomeControllerRoute.GetIndex)), ContentType.Html)); // hub link (Recommended) - The URL for the PubSubHubbub hub. Used to push new entries to subscribers // instead of making them poll the feed. See feed updated method below. feed.Links.Add(new SyndicationLink(new Uri(PubSubHubbubHubUrl), "hub", null, null, 0)); // first, last, next previous (Optional) - Atom 1.0 supports paging of your feed. This is good if your feed // becomes very large and needs splitting up into pages. To add // paging, you must add links to the first, last, next and previous // feed pages. // feed.Links.Add(new SyndicationLink(new Uri("http://example.com/feed"), "first", null, null, 0)); // feed.Links.Add(new SyndicationLink(new Uri("http://example.com/feed?page=10"), "last", null, null, 0)); // if ([HAS_PREVIOUS_PAGE]) // feed.Links.Add(new SyndicationLink(new Uri("http://example.com/feed?page=1")), "previous", null, null, 0)); // if ([HAS_NEXT_PAGE]) // feed.Links.Add(new SyndicationLink(new Uri("http://example.com/feed?page=3"), "next", null, null, 0)); // author (Recommended) - Names one author of the feed. A feed may have multiple author elements. A feed // must contain at least one author element unless all of the entry elements contain // at least one author element. feed.Authors.Add(GetPerson()); // category (Optional) - Specifies a category that the feed belongs to. A feed may have multiple category // elements. feed.Categories.Add(new SyndicationCategory("CategoryName")); // contributor (Optional) - Names one contributor to the feed. An feed may have multiple contributor // elements. feed.Contributors.Add(GetPerson()); // icon (Optional) - Identifies a small image which provides iconic visual identification for the feed. // Icons should be square. feed.SetIcon(_urlHelper.AbsoluteContent("~/content/icons/atom-icon-48x48.png")); // Add the Yahoo Media namespace (xmlns:media="http://search.yahoo.com/mrss/") to the Atom feed. // This gives us extra abilities, like the ability to give thumbnail images to entries. // See http://www.rssboard.org/media-rss for more information. feed.AddYahooMediaNamespace(); return(feed); }