internal static Application CreateApplication(EFProviders.MemberShip ms, string appName) { Application entity = new Application { Id = Guid.NewGuid(), Name = appName }; ms.AddToApplication(entity); return entity; }
/// <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; }
/// <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; }
/// <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; }