public Task <AdminUser> AddAdminUser(AdminUser adminUser) { var adminUserExist = _adminUserRepository.GetByEmail(adminUser.Email).Result; if (adminUserExist != null) { throw new ArgumentException(string.Format("User with Email {0} already used", adminUser.Email), "email"); } _adminUserRepository.Add(adminUser); var saved = _adminUserRepository.SaveChangesAsync().Result; if (!saved) { return(null); } return(_adminUserRepository.Get(adminUser.Id)); }
public IEnumerable <AdminRole> GetAdminRoles(string adminUserId) { var adminUser = _adminUserRepository.Get(adminUserId, "AdminUserRoles.AdminRole").Result; if (adminUser == null) { return(new List <AdminRole>()); } return(adminUser.AdminUserRoles.Select(a => a.AdminRole)); }
public Task GetProfileDataAsync(ProfileDataRequestContext context) { var adminUser = _AdminUserRepository.Get(context.Subject.GetSubjectId(), "AdminUserRoles.AdminUser").Result; context.IssuedClaims.Add(new Claim("email", adminUser.Email)); context.IssuedClaims.Add(new Claim("firstName", adminUser.FirstName)); context.IssuedClaims.Add(new Claim("lastName", adminUser.LastName)); if (adminUser.AdminUserRoles.Where(u => u.AdminRoleId == 0).Count() > 0) { context.IssuedClaims.Add(new Claim("role", "SuperAdmin")); } //if (context.RequestedClaimTypes.Any()) //{ // context.IssuedClaims.Add(new Claim("role", "superAdmin")); // context.IssuedClaims.Add(new Claim("role", "clientAdmin")); // context.IssuedClaims.Add(new Claim("role", "userAdmin")); //} return(Task.FromResult(0)); }