public ICollection <AspNetIdentityUserClaim> AspNetIdentityUserClaims(GStoreData.Models.UserProfile userProfile) { Identity.AspNetIdentityUser user = AspNetIdentityUser(userProfile); if (user == null) { return(null); } return(user.Claims); }
public List <AspNetIdentityRole> AspNetIdentityRoles(GStoreData.Models.UserProfile userProfile) { Identity.AspNetIdentityUser user = AspNetIdentityUser(userProfile); if (user == null) { return(null); } var query = from userRole in user.Roles join role in this.Roles on userRole.RoleId equals role.Id select role; return(query.ToList()); }
public Identity.AspNetIdentityUser AspNetIdentityUser(GStoreData.Models.UserProfile userProfile) { if (userProfile == null) { throw new ApplicationException("User profile is null, cannot check identity user with null profile"); } Identity.AspNetIdentityContext ctx = new Identity.AspNetIdentityContext(); Identity.AspNetIdentityUser user = ctx.Users.SingleOrDefault(usr => usr.Id == userProfile.UserId); if (user == null) { throw new ApplicationException("AspNetUser not found. Check for extra profiles in UserProfile table with duplicate email address." + "\n\tUserId (from profile): " + userProfile.UserId + "\n\tEmail (from profile): " + userProfile.Email + "\n\tUserProfileId (from profile): " + userProfile.UserProfileId); } return(user); }