Ejemplo n.º 1
0
 internal static Application CreateApplication(EFProviders.MemberShip ms, string appName)
 {
     Application entity = new Application
     {
         Id = Guid.NewGuid(),
         Name = appName
     };
     ms.AddToApplication(entity);
     return entity;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Checks the user.
        /// </summary>
        /// <param name="username">The username.</param>
        /// <param name="applicationName">Name of the application.</param>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public static bool CheckUser(string username, string applicationName, EFProviders.MemberShip context)
        {
            User user = context.User.Where(u => u.Username == username && u.Application.Name == applicationName).FirstOrDefault();
            if (user == null)
            {
                return false;
            }

            return true;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get user from database. Throws an error if the user could not be found.
        /// </summary>
        /// <param name="query">The user query.</param>
        /// <param name="context">The context.</param>
        /// <returns>Found user entity.</returns>
        private User GetUser(Expression<Func<User, bool>> query, EFProviders.MemberShip context)
        {
            User user = context.User.Where(query).Where(MatchApplication()).FirstOrDefault();
            if (user == null)
            {
                throw new ProviderException("The supplied user name could not be found.");
            }

            return user;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Get role from database. Throws an error if the role could not be found.
        /// </summary>
        /// <param name="query">The role query.</param>
        /// <param name="context">The context.</param>
        /// <returns>Found role entity.</returns>
        private Role GetRole(Expression<Func<Role, bool>> query, EFProviders.MemberShip context)
        {
            Role role = context.Role.Where(query).Where(MatchRoleApplication()).FirstOrDefault();
            if (role == null)
            {
                throw new ProviderException("The supplied role name could not be found.");
            }

            return role;
        }