public async Task <ResultData <RetrospectorUser> > CreateUserAsync(string email, string roleName) { if (string.IsNullOrEmpty(email)) { return(new ResultData <RetrospectorUser>(EmailNullMessage, false)); } if (string.IsNullOrEmpty(roleName)) { return(new ResultData <RetrospectorUser>(RoleNameEmptyMessage, false)); } RetrospectorUser user = await _accountsRepository.GetUserByEmailAsync(email); if (user != null) { string userFoundMessage = string.Format(UserIsFoundMessage, email); return(new ResultData <RetrospectorUser>(userFoundMessage, true, user)); } user = new RetrospectorUser { Email = email, UserName = email, Notes = new List <Note>(), TeamUsers = new List <TeamUser>(), OwnedTeams = new List <Team>() }; IdentityResult identityResult = await _accountsRepository.AddUserAsync(user); if (!identityResult.Succeeded) { return(new ResultData <RetrospectorUser>(UserCreateFailMessage, false)); } Result roleResult = await AssginToRoleUserAsync(user, roleName); if (!roleResult.Success) { string roleMessage = string.Format(AssignToUserRoleFailMessage, email); return(new ResultData <RetrospectorUser>(roleMessage, false)); } string message = string.Format(UserCreateSuccessMessage, user.Email); return(new ResultData <RetrospectorUser>(message, true, user)); }