public async Task CreateUserInviteListDuplicateInvite() { _userInviteRepositoryMock.SetupCreateItemQuery(o => new List <UserInvite> { new UserInvite { Id = Guid.NewGuid(), FirstName = "abc", LastName = "xyz", Email = "*****@*****.**" } }); _userRepositoryMock.SetupCreateItemQuery(); var createUserInviteRequest = new List <UserInvite> { new UserInvite { FirstName = "abc", LastName = "xyz", Email = "*****@*****.**" } }; var tenantId = Guid.NewGuid(); _tenantApiMock.Setup(m => m.GetTenantDomainsAsync(It.IsAny <Guid>())) .ReturnsAsync(MicroserviceResponse.Create <IEnumerable <TenantDomain> >(HttpStatusCode.OK, new List <TenantDomain> { new TenantDomain { Domain = "yopmail.com" } })); var userInvite = await _controller.CreateUserInviteListAsync(createUserInviteRequest, tenantId); Assert.NotNull(userInvite); Assert.Equal(InviteUserStatus.DuplicateUserEmail, userInvite.ElementAt(0).Status); }
private async Task <object> CreateUserInviteListForTenantAsync() { await RequiresAccess() .WithPrincipalIdExpansion(_ => PrincipalId) .ExecuteAsync(CancellationToken.None); List <UserInvite> invitedUsersList; try { invitedUsersList = this.Bind <List <UserInvite> >(); } catch (Exception ex) { Logger.Error("Binding failed while attempting send user invite", ex); return(Response.BadRequestBindingException()); } try { var result = await _userInviteController.CreateUserInviteListAsync(invitedUsersList, TenantId); return(Negotiate .WithModel(result) .WithStatusCode(HttpStatusCode.Created)); } catch (ValidationFailedException ex) { return(Response.BadRequestValidationFailed(ex.Errors)); } catch (Exception ex) { Logger.Error("Failed to send an invite due to an error", ex); return(Response.InternalServerError(ResponseReasons.InternalServerErrorCreateUser)); } }