Exemplo n.º 1
0
		public static MvcHtmlString LanguageLink(this HtmlHelper htmlHelper, Language language, ViewContext viewContext)
		{
			var controllerName = viewContext.Controller.ControllerContext.RouteData.Values["controller"].ToString();
			var actionName = viewContext.Controller.ControllerContext.RouteData.Values["action"].ToString();

			var currentLanguage = (Language)viewContext.ViewBag.CurrentLanguage;

			var isCurrentLanguage = language == currentLanguage;

			var css = "btn";
			if (isCurrentLanguage)
				css += " btn-success";
			else
				css += " btn-default";

			var routeValues = new RouteValueDictionary(viewContext.Controller.ControllerContext.RouteData.Values);
			routeValues["language"] = language;

			return htmlHelper.ActionLink(language.GetDescription(), actionName, controllerName, routeValues, new Dictionary<string, object> { { "class", css } });
		}