本文整理汇总了C#中System.Web.Mvc.UrlHelper.RecipeDetailUrl方法的典型用法代码示例。如果您正苦于以下问题:C# UrlHelper.RecipeDetailUrl方法的具体用法?C# UrlHelper.RecipeDetailUrl怎么用?C# UrlHelper.RecipeDetailUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Mvc.UrlHelper
的用法示例。
在下文中一共展示了UrlHelper.RecipeDetailUrl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateXml
/// <summary>
/// Generates the Xml Sitemap
/// </summary>
/// <param name="urlHelper"> </param>
public string GenerateXml(UrlHelper urlHelper)
{
var xml = new StringBuilder();
xml.AppendLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
xml.Append("<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" " +
"xmlns:image=\"http://www.sitemaps.org/schemas/sitemap-image/1.1\" " +
"xmlns:video=\"http://www.sitemaps.org/schemas/sitemap-video/1.1\">");
xml.AppendLine();
#region STATIC LINKS
// Add the Static Links
StaticLinks.ForEach(x => xml.AppendLine(this.CreateUrlString(x, new DateTime(2012, 08, 14), "weekly")));
#endregion
#region STYLES
// Add the Recipe Style Detail Page Links
var styles = this.BeerStyleService.GetStyleSummaries();
foreach(var style in styles)
{
xml.AppendLine(this.CreateUrlString(urlHelper.StyleDetailUrl(style.UrlFriendlyName), DateTime.Now, "daily", "1.0"));
var stylePageCount = this.BeerStyleService.GetStylePageCount(style.SubCategoryId);
for(var page = 2; page <= stylePageCount; page++)
{
xml.AppendLine(this.CreateUrlString(urlHelper.StyleDetailUrl(style.UrlFriendlyName, page), DateTime.Now, "daily", "1.0"));
}
}
#endregion
#region UNCATEGORIZED
// Add the Uncategorized Pages
//http://dev.brewgr.com/recipes/other-homebrew-recipes
var uncategorizedPageCount = this.BeerStyleService.GetUnCategorizedRecipesPageCount();
if(uncategorizedPageCount > 0)
{
xml.AppendLine(this.CreateUrlString(urlHelper.Action("other-homebrew-recipes", "Recipe", new { page = (int?)null }, "http"), DateTime.Now, "daily", "1.0"));
if(uncategorizedPageCount > 1)
{
for(var page = 2; page <= uncategorizedPageCount; page++)
{
xml.AppendLine(this.CreateUrlString(urlHelper.Action("other-homebrew-recipes", "Recipe", new { page = page }, "http"), DateTime.Now, "daily", "1.0"));
}
}
}
#endregion
#region RECIPE DETAIL
// Add the Recipe Links (this will need to be extracted when we hit thousands of Recipes)
var recipes = this.RecipeService.GetAllRecipes();
recipes.ForEach(x => xml.AppendLine(this.CreateUrlString(urlHelper.RecipeDetailUrl(x.RecipeId, x.RecipeName, (x.BjcpStyle != null ? x.BjcpStyle.SubCategoryName : null)), x.DateModified ?? x.DateCreated, "weekly", "1.0")));
#endregion
#region BREW SESSION DETAIL
var brewSessions = this.RecipeService.GetAllBrewSessionSummaries();
brewSessions.ForEach(x => xml.AppendLine(this.CreateUrlString(urlHelper.BrewSessionDetailUrl(x.BrewSessionId, x.RecipeName), x.DateModified ?? x.DateCreated, "weekly", "1.0")));
#endregion
#region USER PROFILES
// Add the User Profile Links (this will need to be extracted when we have a lot of users)
var users = this.UserService.GetAllUsers();
users.ForEach(x => xml.AppendLine(this.CreateUrlString(urlHelper.UserProfileUrl(x.CalculatedUsername), x.DateModified ?? x.DateCreated, "weekly", "0.6")));
#endregion
xml.Append("</urlset>");
return xml.ToString();
}