コード例 #1
0
        public async Task <IActionResult> DeleteUserProfile(int profileId)
        {
            var deleteUserProfileCommand = new DeleteUserProfileCommand(profileId);
            var result = await mediator.Send(deleteUserProfileCommand);

            return(StatusCode((int)result.Code, result.Value));
        }
コード例 #2
0
        async Task <DeleteUserProfileCommandResult> IRequestHandler <DeleteUserProfileCommand, DeleteUserProfileCommandResult> .Handle(DeleteUserProfileCommand request, CancellationToken cancellationToken)
        {
            Log.Information("Deleting user profile...", request);
            var result = await _store.DeleteItem(request.UserId, cancellationToken);

            if (result.Result == ResultType.Notfound)
            {
                Log.Information($"Could not find user profile user with ID {request.UserId}.", result);
                return(new DeleteUserProfileCommandResult(request));
            }
            else
            {
                Log.Information("Succesfully deleted user profile.", result);

                var commandResult = new DeleteUserProfileCommandResult(request, result);
                commandResult.AddDomainEvent(UserProfileDeletedDomainEvent.Create(request.UserId, result.Etag));
                return(commandResult);
            }
        }