Beispiel #1
0
        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}"));
        }
Beispiel #2
0
        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[] { });
        }
Beispiel #3
0
        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);
        }