improve result structure and handling
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using CsharpFp3.Domain;
|
||||
using CsharpFp3.Library;
|
||||
using static CsharpFp3.Library.Logging;
|
||||
using static CsharpFp3.Library.ResultModule;
|
||||
|
||||
namespace CsharpFp3.Infrastructure;
|
||||
|
||||
@@ -17,13 +18,10 @@ public static class InMemoryAccountRepository
|
||||
|
||||
Result<Account, AccountError> GetById(Guid id) =>
|
||||
store.TryGetValue(id, out var account)
|
||||
? LogReturn(
|
||||
$"[Repo] Loaded account {id}",
|
||||
Result<Account, AccountError>.Ok(account)
|
||||
)
|
||||
? LogReturn($"[Repo] Loaded account {id}", Ok(account))
|
||||
: LogReturn(
|
||||
$"[Repo] Account {id} not found",
|
||||
Result<Account, AccountError>.Fail(new AccountError.AccountNotFound(id))
|
||||
Fail(new AccountError.AccountNotFound(id))
|
||||
);
|
||||
|
||||
Result<Account, AccountError> Save(Account account)
|
||||
@@ -33,7 +31,7 @@ public static class InMemoryAccountRepository
|
||||
// no failure modes here
|
||||
return LogReturn(
|
||||
$"[Repo] Saved account {account.Id} with balance {account.Balance.Amount:0.00}",
|
||||
Result<Account, AccountError>.Ok(account)
|
||||
Ok(account)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user