Skip to content

If / Then - Statements, How can I achieve this functionally speaking? If value == xx, do this, else, do that #477

Answered by rutkowskit
jeffward01 asked this question in Q&A
Discussion options

You must be logged in to vote

There are at least 2 options.

Option 1:

        Result.Success(_myDateProvider)
            .TapIf(appUserId.IsNullOrDefault(), MarkUpdate)
            .TapIf(appUserId.IsNullOrDefault() is false, dp => MarkUpdate(appUserId.Value, dp));

Option 2:

        Result.SuccessIf(appUserId.IsNullOrDefault(), "appUserId not set")            
            .Tap(() => MarkUpdate(_myDateProvider))
            .TapError(() => MarkUpdate(appUserId.Value, _myDateProvider));    

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jeffward01
Comment options

Answer selected by jeffward01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants