1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-14 11:23:42 +02:00
Sonarr/NzbDrone.Web/Helpers/IsCurrentActionHelper.cs

37 lines
1.1 KiB
C#
Raw Normal View History

using System.Linq;
using System;
2010-10-02 22:01:43 +03:00
using System.Web.Mvc;
using System.Web.Mvc.Html;
2011-04-10 05:44:01 +03:00
namespace NzbDrone.Web.Helpers
2010-10-02 22:01:43 +03:00
{
public static class IsCurrentActionHelper
{
private static bool IsCurrentController(HtmlHelper helper, string actionName, string controllerName)
{
2011-04-10 05:44:01 +03:00
var currentControllerName = (string) helper.ViewContext.RouteData.Values["controller"];
2010-10-02 22:01:43 +03:00
if (currentControllerName.Equals(controllerName, StringComparison.CurrentCultureIgnoreCase))
return true;
return false;
}
2011-04-10 05:44:01 +03:00
public static string CurrentActionLink(this HtmlHelper helper, string text, string actionName,
string controllerName)
2010-10-02 22:01:43 +03:00
{
string result;
if (IsCurrentController(helper, actionName, controllerName))
{
result = "<li class='current_page_item'>";
}
else
{
result = "<li>";
}
return result + helper.ActionLink(text, actionName, controllerName).ToHtmlString() + @"</li>";
}
}
2011-04-10 05:44:01 +03:00
}