public static MvcHtmlString FIO(this HtmlHelper html) { var name = html.ViewContext.HttpContext.User.Identity.Name; var rep = new NHUserRepository(); var user = rep.GetByLogin(name); return(MvcHtmlString.Create($"😠 {user.FirstName} {user.LastName}")); }
public override string[] GetRolesForUser(string username) { var userRepository = new NHUserRepository(); var user = userRepository.GetByLogin(username); if (user != null && user.Role != null) { return(new[] { user.Role.Name }); } return(new string[] { }); }
public override bool IsUserInRole(string username, string roleName) { var userRepository = new NHUserRepository(); var user = userRepository.GetByLogin(username); if (user != null && user.Role != null && user.Role.Name == roleName) { return(true); } return(false); }