This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Purchasing an item: | |
1. must have enough credits | |
2. must have an active account | |
*/ | |
OneOf<PurchaseReceipt, InsufficientCredits, AccountIsSuspended> PurchaseItem(); | |
/* Upvoting a post | |
1. Must have enough reputation points | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public OneOf<User, InvalidUsername, UsernameTaken> CreateUser(string username) | |
{ | |
if (!IsValid(username)) | |
{ | |
return new InvalidUsername(username); | |
} | |
if (UsernameTaken(username)) | |
{ | |
return new UsernameTaken(username); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Result<User> CreateUser(string username) | |
{ | |
if (!IsValid(username)) | |
{ | |
return Result.Fail("Invalid username"); | |
} | |
if (UsernameTaken(username)) | |
{ | |
return Result.Fail("Username already taken"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public User CreateUser(string username) | |
{ | |
if (!IsValid(username)) | |
{ | |
throw new InvalidOperationException("Invalid username"); | |
} | |
if (UsernameTaken(username)) | |
{ | |
throw new InvalidOperationException("Username already taken"); |