Skip to content

Commit 16d2c5c

Browse files
committed
Arrows formatting
ToString for ProductItemsList Fixed when for ShoppingCart Cleaned obsolete methods of EventStoreDBRepository
1 parent d762c2a commit 16d2c5c

File tree

12 files changed

+59
-72
lines changed

12 files changed

+59
-72
lines changed

Core.Api.Testing/TestContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public TestContext(
2424
{
2525
}
2626

27-
private static IWebHostBuilder SetupWebHostBuilder(IWebHostBuilder webHostBuilder)
28-
=> webHostBuilder.UseStartup<TStartup>();
27+
private static IWebHostBuilder SetupWebHostBuilder(IWebHostBuilder webHostBuilder) =>
28+
webHostBuilder.UseStartup<TStartup>();
2929
}
3030

3131
public class TestContext: IDisposable

EventSourcing.NetCore.sln

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ECommerce", "Sample\EventSt
212212
EndProject
213213
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ECommerce.Api.Tests", "Sample\EventStoreDB\Simple\ECommerce.Api.Tests\ECommerce.Api.Tests.csproj", "{36C7CF36-254A-48D5-8181-9196DB1A034B}"
214214
EndProject
215-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core.Api.Testing", "Core.Api.Testing\Core.Api.Testing.csproj", "{5258F44A-9B51-4F7F-BBB8-D4C81A921C4F}"
215+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core.Api.Testing", "Core.Api.Testing\Core.Api.Testing.csproj", "{E96D4B8C-AF32-4434-BB5D-5C88675DC084}"
216216
EndProject
217217
Global
218218
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -484,10 +484,10 @@ Global
484484
{36C7CF36-254A-48D5-8181-9196DB1A034B}.Debug|Any CPU.Build.0 = Debug|Any CPU
485485
{36C7CF36-254A-48D5-8181-9196DB1A034B}.Release|Any CPU.ActiveCfg = Release|Any CPU
486486
{36C7CF36-254A-48D5-8181-9196DB1A034B}.Release|Any CPU.Build.0 = Release|Any CPU
487-
{5258F44A-9B51-4F7F-BBB8-D4C81A921C4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
488-
{5258F44A-9B51-4F7F-BBB8-D4C81A921C4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
489-
{5258F44A-9B51-4F7F-BBB8-D4C81A921C4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
490-
{5258F44A-9B51-4F7F-BBB8-D4C81A921C4F}.Release|Any CPU.Build.0 = Release|Any CPU
487+
{E96D4B8C-AF32-4434-BB5D-5C88675DC084}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
488+
{E96D4B8C-AF32-4434-BB5D-5C88675DC084}.Debug|Any CPU.Build.0 = Debug|Any CPU
489+
{E96D4B8C-AF32-4434-BB5D-5C88675DC084}.Release|Any CPU.ActiveCfg = Release|Any CPU
490+
{E96D4B8C-AF32-4434-BB5D-5C88675DC084}.Release|Any CPU.Build.0 = Release|Any CPU
491491
EndGlobalSection
492492
GlobalSection(SolutionProperties) = preSolution
493493
HideSolutionNode = FALSE
@@ -571,11 +571,11 @@ Global
571571
{CCE3A700-BCB2-4639-B766-ECEB2E804D63} = {0570E45A-2EB6-4C4C-84E4-2C80E1FECEB5}
572572
{B32E504C-C17A-419B-A705-6B876EF44854} = {0570E45A-2EB6-4C4C-84E4-2C80E1FECEB5}
573573
{D9D67A6C-FE95-4864-B8F1-BD2689134590} = {107B18E3-65C8-4A6C-976D-7EEED6A6D318}
574-
{825A40DB-5AB5-4565-AADB-28AC760D0A43} = {0570E45A-2EB6-4C4C-84E4-2C80E1FECEB5} {11DD4963-5BB4-4E1B-9475-8EB10C822BFC} = {9C5C1CB3-B8CD-4CEE-A5F2-5983770C60BB}
574+
{11DD4963-5BB4-4E1B-9475-8EB10C822BFC} = {9C5C1CB3-B8CD-4CEE-A5F2-5983770C60BB}
575575
{414D1D34-1002-4159-B738-DF3EE042F9FD} = {11DD4963-5BB4-4E1B-9475-8EB10C822BFC}
576576
{C8CBBED5-8999-4643-96E6-E56B3A940F97} = {11DD4963-5BB4-4E1B-9475-8EB10C822BFC}
577577
{36C7CF36-254A-48D5-8181-9196DB1A034B} = {11DD4963-5BB4-4E1B-9475-8EB10C822BFC}
578-
{5258F44A-9B51-4F7F-BBB8-D4C81A921C4F} = {0570E45A-2EB6-4C4C-84E4-2C80E1FECEB5}
578+
{E96D4B8C-AF32-4434-BB5D-5C88675DC084} = {0570E45A-2EB6-4C4C-84E4-2C80E1FECEB5}
579579
EndGlobalSection
580580
GlobalSection(ExtensibilityGlobals) = postSolution
581581
SolutionGuid = {A5F55604-2FF3-43B7-B657-4F18E6E95D3B}

Sample/EventStoreDB/Simple/ECommerce.Core/Commands/CommandHandler.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ public static IServiceCollection AddCreateCommandHandler<TCommand, TEntity>(
4444
this IServiceCollection services,
4545
Func<TCommand, object> handle,
4646
Func<TCommand, string> getId
47-
) where TEntity : notnull
48-
=> AddCreateCommandHandler<TCommand, TEntity>(services, _ => handle, getId);
47+
) where TEntity : notnull =>
48+
AddCreateCommandHandler<TCommand, TEntity>(services, _ => handle, getId);
4949

5050
public static IServiceCollection AddCreateCommandHandler<TCommand, TEntity>(
5151
this IServiceCollection services,
5252
Func<IServiceProvider, Func<TCommand, object>> handle,
5353
Func<TCommand, string> getId
54-
) where TEntity : notnull
55-
=> services
54+
) where TEntity : notnull =>
55+
services
5656
.AddTransient<Func<TCommand, CancellationToken, ValueTask>>(sp =>
5757
{
5858
var repository = sp.GetRequiredService<IEventStoreDBRepository<TEntity>>();
@@ -68,24 +68,22 @@ public static IServiceCollection AddUpdateCommandHandler<TCommand, TEntity>(
6868
Func<TCommand, string> getId,
6969
Func<TCommand, uint> getVersion,
7070
Func<TEntity?, object, TEntity> when
71-
) where TEntity : notnull
72-
=> AddUpdateCommandHandler(services, _ => handle, getId, getVersion, when);
71+
) where TEntity : notnull =>
72+
AddUpdateCommandHandler(services, _ => handle, getId, getVersion, when);
7373

7474
public static IServiceCollection AddUpdateCommandHandler<TCommand, TEntity>(
7575
this IServiceCollection services,
7676
Func<IServiceProvider, Func<TCommand, TEntity, object>> handle,
7777
Func<TCommand, string> getId,
7878
Func<TCommand, uint> getVersion,
7979
Func<TEntity?, object, TEntity> when
80-
) where TEntity : notnull
81-
=> services
80+
) where TEntity : notnull =>
81+
services
8282
.AddTransient<Func<TCommand, CancellationToken, ValueTask>>(sp =>
8383
{
8484
var repository = sp.GetRequiredService<IEventStoreDBRepository<TEntity>>();
8585
return async (command, ct) =>
8686
await HandleUpdateCommand(repository, handle(sp), getId, getVersion, when, command, ct);
8787
});
88-
89-
9088
}
9189
}

Sample/EventStoreDB/Simple/ECommerce.Core/Entities/EventStoreDBRepository.cs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ CancellationToken cancellationToken
5959
{
6060
await eventStore.AppendToStreamAsync(
6161
id,
62-
// TODO: Add proper optimistic concurrency handling
6362
StreamState.NoStream,
6463
new[] { @event.ToJsonEventData() },
6564
cancellationToken: cancellationToken
@@ -81,28 +80,13 @@ await eventStore.AppendToStreamAsync(
8180
cancellationToken: cancellationToken
8281
);
8382
}
84-
85-
private async Task Append(
86-
string id,
87-
object @event,
88-
uint? version,
89-
CancellationToken cancellationToken
90-
)
91-
{
92-
await eventStore.AppendToStreamAsync(
93-
id,
94-
// TODO: Add proper optimistic concurrency handling
95-
StreamState.Any,
96-
new[] { @event.ToJsonEventData() },
97-
cancellationToken: cancellationToken
98-
);
99-
}
10083
}
10184

10285
public static class EventStoreDBRepository
10386
{
104-
public static IServiceCollection AddEventStoreDBRepository<TEntity>(this IServiceCollection services)
105-
where TEntity : class
106-
=> services.AddTransient<IEventStoreDBRepository<TEntity>, EventStoreDBRepository<TEntity>>();
87+
public static IServiceCollection AddEventStoreDBRepository<TEntity>(
88+
this IServiceCollection services
89+
) where TEntity : class =>
90+
services.AddTransient<IEventStoreDBRepository<TEntity>, EventStoreDBRepository<TEntity>>();
10791
}
10892
}

Sample/EventStoreDB/Simple/ECommerce.Core/Events/EventBus.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ private static MethodInfo GetGenericPublishFor(object @event)
6767

6868
public static class EventBusExtensions
6969
{
70-
public static IServiceCollection AddEventBus(this IServiceCollection services)
71-
=> services.AddSingleton<IEventBus, EventBus>(sp =>
70+
public static IServiceCollection AddEventBus(this IServiceCollection services) =>
71+
services.AddSingleton<IEventBus, EventBus>(sp =>
7272
new EventBus(sp, Policy.Handle<Exception>().RetryAsync(3)));
7373
}
7474
}

Sample/EventStoreDB/Simple/ECommerce.Core/Queries/QueryHandler.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ Func<IQueryable<TResult>, TQuery, CancellationToken, Task<IReadOnlyList<TResult>
4646
handler(queryable, query, ct);
4747
});
4848

49-
public static IServiceCollection AddQueryHandler<TQuery, TResult>(this IServiceCollection services,
50-
Func<IServiceProvider, Func<TQuery, CancellationToken, Task<TResult>>> setup)
51-
=> services.AddTransient(setup);
49+
public static IServiceCollection AddQueryHandler<TQuery, TResult>(
50+
this IServiceCollection services,
51+
Func<IServiceProvider, Func<TQuery, CancellationToken, Task<TResult>>> setup
52+
) =>
53+
services.AddTransient(setup);
5254
}
5355
}

Sample/EventStoreDB/Simple/ECommerce.Core/Serialisation/EventStoreDBSerializer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ namespace ECommerce.Core.Serialisation
77
{
88
public static class EventStoreDBSerializer
99
{
10-
public static T Deserialize<T>(this ResolvedEvent resolvedEvent)
11-
=> (T)Deserialize(resolvedEvent);
10+
public static T Deserialize<T>(this ResolvedEvent resolvedEvent) =>
11+
(T)Deserialize(resolvedEvent);
1212

1313
public static object Deserialize(this ResolvedEvent resolvedEvent)
1414
{

Sample/EventStoreDB/Simple/ECommerce/Configuration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ namespace ECommerce
99
{
1010
public static class Configuration
1111
{
12-
public static IServiceCollection AddECommerceModule(this IServiceCollection services)
13-
=> services
12+
public static IServiceCollection AddECommerceModule(this IServiceCollection services) =>
13+
services
1414
.AddShoppingCartsModule()
1515
.AddPricingModule()
1616
.AddDbContext<ECommerceDbContext>(

Sample/EventStoreDB/Simple/ECommerce/Pricing/Configuration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace ECommerce.Pricing
55
{
66
public static class Configuration
77
{
8-
public static IServiceCollection AddPricingModule(this IServiceCollection services)
9-
=> services.AddSingleton<IProductPriceCalculator, RandomProductPriceCalculator>();
8+
public static IServiceCollection AddPricingModule(this IServiceCollection services) =>
9+
services.AddSingleton<IProductPriceCalculator, RandomProductPriceCalculator>();
1010
}
1111
}

Sample/EventStoreDB/Simple/ECommerce/ShoppingCarts/Configuration.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,20 @@ namespace ECommerce.ShoppingCarts
1616
{
1717
public static class Configuration
1818
{
19-
public static IServiceCollection AddShoppingCartsModule(this IServiceCollection services)
20-
=> services
19+
public static IServiceCollection AddShoppingCartsModule(this IServiceCollection services) =>
20+
services
2121
.AddEventStoreDBRepository<ShoppingCart>()
2222
.AddCreateCommandHandler<InitializeShoppingCart, ShoppingCart>(
2323
InitializeShoppingCart.Handle,
2424
command => ShoppingCart.MapToStreamId(command.ShoppingCartId)
2525
)
2626
.AddUpdateCommandHandler<AddProductItemToShoppingCart, ShoppingCart>(
27-
sp=> (command, shoppingCart) =>
28-
AddProductItemToShoppingCart.Handle(
29-
sp.GetRequiredService<IProductPriceCalculator>(),
30-
command,
31-
shoppingCart),
27+
sp =>
28+
(command, shoppingCart) =>
29+
AddProductItemToShoppingCart.Handle(
30+
sp.GetRequiredService<IProductPriceCalculator>(),
31+
command,
32+
shoppingCart),
3233
command => ShoppingCart.MapToStreamId(command.ShoppingCartId),
3334
command => command.Version,
3435
ShoppingCart.When

0 commit comments

Comments
 (0)