HTML Helper Methods
public static class CoverageAuthorization
{
public static MvcHtmlString ShowHideLink( this HtmlHelper helper,string linkSupplied, string username)
{
var approvalHierarchy = ConfigurationManager.AppSettings["ApprovalHierarchy"];
approvalHierarchy = approvalHierarchy.Substring(approvalHierarchy.IndexOf("Supervisor"));
var claimManager = new ClaimManager();
var currentUser = claimManager.GetClaimUserByLogin(username);
if (approvalHierarchy.IndexOf(currentUser.Role.ToString()) >= 0)
{
return MvcHtmlString.Create("<br />" + linkSupplied);
}
else
{
return MvcHtmlString.Empty; ;
}
}
}
To use it
@Html.ShowHideLink("<a href='/CaseLoadTransition/Index'>Case Load Transition</a> ", HttpContext.Current.User.Identity.Name.ToString())
{
public static MvcHtmlString ShowHideLink( this HtmlHelper helper,string linkSupplied, string username)
{
var approvalHierarchy = ConfigurationManager.AppSettings["ApprovalHierarchy"];
approvalHierarchy = approvalHierarchy.Substring(approvalHierarchy.IndexOf("Supervisor"));
var claimManager = new ClaimManager();
var currentUser = claimManager.GetClaimUserByLogin(username);
if (approvalHierarchy.IndexOf(currentUser.Role.ToString()) >= 0)
{
return MvcHtmlString.Create("<br />" + linkSupplied);
}
else
{
return MvcHtmlString.Empty; ;
}
}
}
To use it
@Html.ShowHideLink("<a href='/CaseLoadTransition/Index'>Case Load Transition</a> ", HttpContext.Current.User.Identity.Name.ToString())
Comments