Skip to content

Commit 074fdce

Browse files
committed
- Checkpoint: Event Transformation for View Model
1 parent fad0b7c commit 074fdce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+279
-325
lines changed

src/SourceFlow.ConsoleApp/Impl/InMemoryDomianRepository.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class InMemoryDomianRepository : IDomainRepository
66
{
77
private readonly ConcurrentDictionary<int, IEntity> _cache = new();
88

9-
public Task DeleteAsync<TEntity>(TEntity entity) where TEntity : IEntity
9+
public Task Delete<TEntity>(TEntity entity) where TEntity : IEntity
1010
{
1111
if (entity?.Id == null)
1212
throw new ArgumentNullException(nameof(entity));
@@ -16,7 +16,7 @@ public Task DeleteAsync<TEntity>(TEntity entity) where TEntity : IEntity
1616
return Task.CompletedTask;
1717
}
1818

19-
public Task<TEntity> GetByIdAsync<TEntity>(int id) where TEntity : class, IEntity
19+
public Task<TEntity> Get<TEntity>(int id) where TEntity : class, IEntity
2020
{
2121
if (id == 0)
2222
throw new ArgumentNullException(nameof(id));
@@ -26,7 +26,7 @@ public Task<TEntity> GetByIdAsync<TEntity>(int id) where TEntity : class, IEntit
2626
return Task.FromResult<TEntity>(success ? (TEntity)entity : null);
2727
}
2828

29-
public Task PersistAsync<TEntity>(TEntity entity) where TEntity : IEntity
29+
public Task Persist<TEntity>(TEntity entity) where TEntity : IEntity
3030
{
3131
if (entity?.Id == null)
3232
throw new ArgumentNullException(nameof(entity));

src/SourceFlow.ConsoleApp/Impl/InMemoryEventStore.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class InMemoryEventStore : IEventStore
66
{
77
private readonly ConcurrentDictionary<int, List<IEvent>> _store = new();
88

9-
public Task AppendAsync(IEvent @event)
9+
public Task Append(IEvent @event)
1010
{
1111
if (!_store.ContainsKey(@event.Entity.Id))
1212
_store[@event.Entity.Id] = new List<IEvent>();
@@ -16,7 +16,7 @@ public Task AppendAsync(IEvent @event)
1616
return Task.CompletedTask;
1717
}
1818

19-
public async Task<IEnumerable<IEvent>> LoadAsync(int aggregateId)
19+
public async Task<IEnumerable<IEvent>> Load(int aggregateId)
2020
{
2121
return await Task.FromResult(_store.TryGetValue(aggregateId, out var events)
2222
? events

src/SourceFlow.ConsoleApp/Impl/InMemoryViewModelRepository.cs

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/SourceFlow.ConsoleApp/Impl/InMemoryViewRepository.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class InMemoryViewRepository : IViewModelRepository
66
{
77
private readonly ConcurrentDictionary<int, IViewModel> _cache = new();
88

9-
public Task DeleteAsync<TViewModel>(TViewModel model) where TViewModel : IViewModel
9+
public Task Delete<TViewModel>(TViewModel model) where TViewModel : IViewModel
1010
{
1111
if (model?.Id == null)
1212
throw new ArgumentNullException(nameof(model));
@@ -16,7 +16,7 @@ public Task DeleteAsync<TViewModel>(TViewModel model) where TViewModel : IViewMo
1616
return Task.CompletedTask;
1717
}
1818

19-
public Task<TViewModel> GetByIdAsync<TViewModel>(int id) where TViewModel : class, IViewModel
19+
public Task<TViewModel> Get<TViewModel>(int id) where TViewModel : class, IViewModel
2020
{
2121
if (id == 0)
2222
throw new ArgumentNullException(nameof(id));
@@ -26,7 +26,7 @@ public Task<TViewModel> GetByIdAsync<TViewModel>(int id) where TViewModel : clas
2626
return Task.FromResult<TViewModel>(success ? (TViewModel)model : null);
2727
}
2828

29-
public Task PersistAsync<TViewModel>(TViewModel model) where TViewModel : IViewModel
29+
public Task Persist<TViewModel>(TViewModel model) where TViewModel : IViewModel
3030
{
3131
if (model?.Id == null)
3232
throw new ArgumentNullException(nameof(model));

src/SourceFlow.ConsoleApp/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using Microsoft.Extensions.DependencyInjection;
22
using Microsoft.Extensions.Logging;
33
using SourceFlow;
4-
using SourceFlow.ConsoleApp.Projections;
5-
using SourceFlow.ConsoleApp.Services; // Ensure this using is present
4+
using SourceFlow.ConsoleApp.Services;
5+
using SourceFlow.ConsoleApp.ViewModels; // Ensure this using is present
66

77
var services = new ServiceCollection();
88

src/SourceFlow.ConsoleApp/Projections/AccountSummaryProjectionHandler.cs

Lines changed: 0 additions & 74 deletions
This file was deleted.

src/SourceFlow.ConsoleApp/Projections/AccountView.cs

Lines changed: 0 additions & 74 deletions
This file was deleted.

src/SourceFlow.ConsoleApp/Sagas/AccountSaga.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class AccountSaga : BaseSaga<BankAccount>,
1010
IEventHandler<MoneyWithdrawn>,
1111
IEventHandler<AccountClosed>
1212
{
13-
public async Task HandleAsync(AccountCreated @event)
13+
public async Task Handle(AccountCreated @event)
1414
{
1515
logger.LogInformation("Action=Account_Created, Account={AccountId}, Holder={AccountName}, Initial_Balance={InitialBalance}",
1616
@event.Entity.Id, @event.Payload.AccountName, @event.Payload.InitialAmount);
@@ -31,7 +31,7 @@ public async Task HandleAsync(AccountCreated @event)
3131
await PersistAggregate(account);
3232
}
3333

34-
public async Task HandleAsync(MoneyDeposited @event)
34+
public async Task Handle(MoneyDeposited @event)
3535
{
3636
logger.LogInformation("Action=Money_Deposited, Amount={Amount}, Account={AccountId}", @event.Payload.Amount, @event.Entity.Id);
3737

@@ -49,7 +49,7 @@ public async Task HandleAsync(MoneyDeposited @event)
4949
await PersistAggregate(account);
5050
}
5151

52-
public async Task HandleAsync(MoneyWithdrawn @event)
52+
public async Task Handle(MoneyWithdrawn @event)
5353
{
5454
logger.LogInformation("Action=Money_Withdrawn, Amount={Amount}, Account={AccountId}", @event.Payload.Amount, @event.Entity.Id);
5555

@@ -67,7 +67,7 @@ public async Task HandleAsync(MoneyWithdrawn @event)
6767
await PersistAggregate(account);
6868
}
6969

70-
public async Task HandleAsync(AccountClosed @event)
70+
public async Task Handle(AccountClosed @event)
7171
{
7272
logger.LogInformation("Action=Account_Closed, Account={AccountId}, Reason={Reason}", @event.Entity.Id, @event.Payload.ClosureReason);
7373

src/SourceFlow.ConsoleApp/Services/AccountViewFinder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using SourceFlow.ConsoleApp.Projections;
1+
using SourceFlow.ConsoleApp.ViewModels;
22

33
namespace SourceFlow.ConsoleApp.Services
44
{

src/SourceFlow.ConsoleApp/Projections/AccountViewModel.cs renamed to src/SourceFlow.ConsoleApp/ViewModels/AccountViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace SourceFlow.ConsoleApp.Projections
1+
namespace SourceFlow.ConsoleApp.ViewModels
22
{
33
public class AccountViewModel : IViewModel
44
{

0 commit comments

Comments
 (0)