improve result structure and handling

This commit is contained in:
Oli Sturm
2026-05-04 19:39:49 +01:00
parent 0d02927ba6
commit 73ed4c7b9c
14 changed files with 413 additions and 371 deletions
@@ -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)
);
}