Beispiel #1
0
        public override string[] FindUsersInRole(string roleName, string usernameToMatch)
        {
            roleName        = roleName.ToLower();
            usernameToMatch = usernameToMatch.ToLower();
            var userNames = new List <string>();

            if (!string.IsNullOrEmpty(roleName))
            {
                try
                {
                    using (var context = new ExHolidayEntities())
                    {
                        userNames = context.tblmembers
                                    .Where(a =>
                                           a.Active &&
                                           a.Roles.ToLower().Contains(roleName) &&
                                           a.PICEmail.ToLower() == usernameToMatch)
                                    .Select(a => a.PICEmail).ToList();
                    }
                }
                catch (Exception ex)
                {
                    ex.Log();
                    throw;
                }
            }

            return(userNames.ToArray());
        }
Beispiel #2
0
        public override string[] GetRolesForUser(string username)
        {
            var roles = new List <string>();

            if (string.IsNullOrEmpty(username))
            {
                return(roles.ToArray());
            }

            try
            {
                username = username.ToLower();
                using (var context = new ExHolidayEntities())
                {
                    var access = context.tblmembers.Where(a => a.Active && a.PICEmail.ToLower() == username).SingleOrDefault();
                    if (access == null)
                    {
                        return(roles.ToArray());
                    }

                    roles = access.Roles.Split(',').ToList();
                }
            }
            catch (Exception ex)
            {
                ex.Log();
                throw;
            }

            return(roles.ToArray());
        }
Beispiel #3
0
 public static void SetSessionAccess(string loginID)
 {
     using (var context = new ExHolidayEntities())
     {
         var access = context.tblmembers.Single(a => a.PICEmail.ToLower() == loginID.ToLower() && a.Active);
         Util.SessionAccess = access;
     }
 }
Beispiel #4
0
        public override string[] GetAllRoles()
        {
            var roles = new List <string>();

            try
            {
                using (var context = new ExHolidayEntities())
                {
                    roles = context.refroles.Select(a => a.Role).ToList();
                }
            }
            catch (Exception ex)
            {
                ex.Log();
            }

            return(roles.ToArray());
        }
Beispiel #5
0
        public override bool RoleExists(string roleName)
        {
            bool result = false;

            try
            {
                using (var context = new ExHolidayEntities())
                {
                    result = context.refroles.Any(a => a.Role == roleName);
                }
            }
            catch (Exception ex)
            {
                ex.Log();
                return(result);
            }

            return(result);
        }