コード例 #1
0
        public async Task ResendUserInviteListReturnsUserNotExists()
        {
            _userInviteRepositoryMock.SetupCreateItemQuery();

            var resendUserInviteRequest = new List <UserInvite> {
                new UserInvite {
                    FirstName = "abc", LastName = "xyz", Email = "*****@*****.**"
                }
            };
            var tenantId   = Guid.NewGuid();
            var userInvite = await _controller.ResendEmailInviteAsync(resendUserInviteRequest, tenantId);

            Assert.NotNull(userInvite);
            Assert.Equal(InviteUserStatus.UserNotExist, userInvite.ElementAt(0).Status);
        }
        private async Task <object> ResendEmailInvitationAsync()
        {
            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 to resend user invites", ex);
                return(Response.BadRequestBindingException());
            }

            try
            {
                var result = await _userInviteController.ResendEmailInviteAsync(invitedUsersList, TenantId);

                return(Negotiate
                       .WithModel(result)
                       .WithStatusCode(HttpStatusCode.Created));
            }
            catch (ValidationFailedException ex)
            {
                return(Response.BadRequestValidationFailed(ex.Errors));
            }
            catch (Exception ex)
            {
                Logger.Error("Failed to resend an invite due to an error", ex);
                return(Response.InternalServerError(ResponseReasons.InternalServerErrorCreateUser));
            }
        }