Skip to content

Commit

Permalink
Merge pull request #432 from J-Tech-Japan/428-sample-2-4-to-newest
Browse files Browse the repository at this point in the history
Update Sample 2 and Sample 3
  • Loading branch information
tomohisa authored Nov 14, 2024
2 parents fe78954 + f969cd8 commit db33916
Show file tree
Hide file tree
Showing 20 changed files with 726 additions and 54 deletions.
Binary file removed .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,5 @@ MigrationBackup/
FodyWeavers.xsd

**/.idea/

.DS_Store
Binary file removed Samples/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>c94946b2-509e-4fea-a5bf-ac97e8eefb44</UserSecretsId>
<LangVersion>preview</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.7" />
<PackageReference Include="Sekiban.Infrastructure.Cosmos" Version="0.20.3" />
<PackageReference Include="Sekiban.Web" Version="0.20.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2"/>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0" />
<PackageReference Include="Sekiban.Infrastructure.Cosmos" Version="0.22.0-preview9" />
<PackageReference Include="Sekiban.Web" Version="0.22.0-preview9" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.0.0"/>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@ public record ChangeUserPointName(
[property: Required]
string NameToChange) : ICommandWithHandler<UserPoint, ChangeUserPointName>
{
// Aggregate Id should be current aggregate.
public Guid GetAggregateId() => UserPointId;
public static ResultBox<UnitValue> HandleCommand(
ChangeUserPointName command,
ICommandContext<UserPoint> context) =>
ResultBox.Start
.Verify(
_ => context.GetState().Payload.Name == command.NameToChange
? new InvalidOperationException("Already have same name as requested.")
: ExceptionOrNone.None)
.Conveyor(_ => context.AppendEvent(new UserPointNameChanged(command.NameToChange)));
public static Guid SpecifyAggregateId(ChangeUserPointName command) => command.UserPointId;
public static ResultBox<EventOrNone<UserPoint>> HandleCommand(ChangeUserPointName command, ICommandContext<UserPoint> context) =>
ResultBox.Start
.Verify(
_ => context.GetState().Payload.Name == command.NameToChange
? new InvalidOperationException("Already have same name as requested.")
: ExceptionOrNone.None)
.Conveyor(_ => EventOrNone.Event(new UserPointNameChanged(command.NameToChange)));
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ public record CreateUserPoint(
int Point) : ICommandWithHandler<UserPoint, CreateUserPoint>
{
// Assign new Aggregate Id by NewGuid()
public Guid GetAggregateId() => Guid.NewGuid();
public static Guid SpecifyAggregateId(CreateUserPoint command) => Guid.NewGuid();

public static ResultBox<UnitValue> HandleCommand(
CreateUserPoint command,
ICommandContext<UserPoint> context) =>
context.AppendEvent(new UserPointCreated(command.Name, command.Email, command.Point));
public static ResultBox<EventOrNone<UserPoint>> HandleCommand(CreateUserPoint command, ICommandContext<UserPoint> context)
=> context.AppendEvent(new UserPointCreated(command.Name, command.Email, command.Point));
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Sekiban.Core" Version="0.20.3" />
<PackageReference Include="Sekiban.Core" Version="0.22.0-preview9" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<LangVersion>preview</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0"/>
<PackageReference Include="Sekiban.Testing" Version="0.20.3" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1"/>
<PackageReference Include="Sekiban.Testing" Version="0.22.0-preview9" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
Loading

0 comments on commit db33916

Please sign in to comment.