Пример #1
0
        public IList <string> GetRolesForUser(string userName)
        {
            using (var unitOfWork = _unitOfWorkFactory.Create())
            {
                var usersRepository = _usersRepositoryFactory.CreateUsersRepository(unitOfWork);

                try
                {
                    unitOfWork.BeginTransaction();

                    var user = usersRepository.FindBy(n => n.UserName == userName && n.Membership.ApplicationName == _applicationName);

                    unitOfWork.Commit();
                    return(user.Roles.Select(n => n.Name).ToList());
                }
                catch (Exception e)
                {
                    unitOfWork.Rollback();
                    throw new RoleServiceException(
                              string.Format("An error occurred when invoked GetRolesForUser({0}) method.", userName), e);
                }
            }
        }
Пример #2
0
        public IList <Models.UserProfile> GetUsersByEmail(string email)
        {
            using (var unitOfWork = _unitOfWorkFactory.Create())
            {
                try
                {
                    var usersRepository = _usersRepositoryFactory.CreateUsersRepository(unitOfWork);

                    return(usersRepository.FilterBy(n => n.Membership.Email == email && n.Membership.ApplicationName == _applicationName).ToList());
                }
                catch (Exception e)
                {
                    throw new MembershipServiceException(
                              string.Format("An error occurred when invoked GetUsersByEmail({0}) method.", email), e);
                }
            }
        }