Skip to content

Commit 8601a23

Browse files
authored
Merge pull request #49 from codepb/app-service-improvements
App service improvements
2 parents 37829a5 + 39289ac commit 8601a23

27 files changed

+764
-63
lines changed

logo/logo.png

1.84 KB
Loading

samples/library/DDDToolkit.Samples.Library.Domain/DDDToolkit.Samples.Library.Domain.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="FluentQueries" Version="1.1.1" />
8+
<PackageReference Include="FluentQueries" Version="1.3.2" />
99
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
1010
</ItemGroup>
1111

samples/library/DDDToolkit.Samples.Library.UI.Web/DDDToolkit.Samples.Library.UI.Web.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="FluentQueries" Version="1.1.1" />
11+
<PackageReference Include="FluentQueries" Version="1.3.2" />
1212
<PackageReference Include="Microsoft.AspNetCore.All" />
1313
</ItemGroup>
1414

src/DDDToolkit.ApplicationLayer/ApplicationService.cs

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
using DDDToolkit.ApplicationLayer.Transactions;
1+
using DDDToolkit.ApplicationLayer.Repositories;
2+
using DDDToolkit.ApplicationLayer.Transactions;
3+
using DDDToolkit.Core.Interfaces;
4+
using FluentQueries;
5+
using System.Collections.Generic;
6+
using System.Threading;
27
using System.Threading.Tasks;
38

49
namespace DDDToolkit.ApplicationLayer
@@ -16,6 +21,36 @@ protected Task<ITransaction> BeginTransaction()
1621
{
1722
return _unitOfWork.BeginTransaction();
1823
}
24+
protected Task<IReadOnlyCollection<T>> Query<T, TId>(IQuery<T> query, QueryOptions queryOptions = null, CancellationToken cancellationToken = default(CancellationToken)) where T : class, IAggregateRoot<TId>
25+
{
26+
return ReadableRepository<T, TId>().Query(query, queryOptions, cancellationToken);
27+
}
28+
29+
protected Task<T> FirstOrDefault<T, TId>(IQuery<T> query, string[] onlyIncludePaths = null, CancellationToken cancellationToken = default(CancellationToken)) where T : class, IAggregateRoot<TId>
30+
{
31+
return ReadableRepository<T, TId>().FirstOrDefault(query, onlyIncludePaths, cancellationToken);
32+
}
33+
34+
protected Task Add<T, TId>(T entity) where T : class, IAggregateRoot<TId>
35+
{
36+
return WritableRepository<T, TId>().Add(entity);
37+
}
38+
39+
protected Task Update<T, TId>(T entity) where T : class, IAggregateRoot<TId>
40+
{
41+
return WritableRepository<T, TId>().Update(entity);
42+
}
43+
44+
protected Task Remove<T, TId>(TId id) where T : class, IAggregateRoot<TId>
45+
{
46+
return WritableRepository<T, TId>().Remove(id);
47+
}
48+
49+
protected IRepository<T, TId> Repository<T, TId>() where T : class, IAggregateRoot<TId> => _unitOfWork.Repository<T, TId>();
50+
51+
protected IReadableRepository<T, TId> ReadableRepository<T, TId>() where T : class, IAggregateRoot<TId> => _unitOfWork.ReadableRepository<T, TId>();
52+
53+
protected IWritableRepository<T, TId> WritableRepository<T, TId>() where T : class, IAggregateRoot<TId> => _unitOfWork.WritableRepository<T, TId>();
1954

2055
protected Task SaveChanges()
2156
{

src/DDDToolkit.ApplicationLayer/DDDToolkit.ApplicationLayer.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
<RepositoryUrl>https://github.com/codepb/DDDToolkit</RepositoryUrl>
1313
<PackageTags>DDD, Domain Driven Design, Application Layer</PackageTags>
1414
<PackageIconUrl>https://raw.githubusercontent.com/codepb/DDDToolkit/master/logo/logo.png</PackageIconUrl>
15-
<Version>2.0.0</Version>
15+
<Version>2.1.0</Version>
1616
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1717
</PropertyGroup>
1818

1919
<ItemGroup>
20-
<None Include="..\..\LICENSE" Pack="true" PackagePath=""/>
20+
<None Include="..\..\LICENSE" Pack="true" PackagePath="" />
2121
</ItemGroup>
2222

2323
<ItemGroup>
24-
<PackageReference Include="FluentQueries" Version="1.1.1" />
24+
<PackageReference Include="FluentQueries" Version="1.3.2" />
2525
</ItemGroup>
2626

2727
<ItemGroup>

src/DDDToolkit.ApplicationLayer/ReadableApplicationService.cs

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

src/DDDToolkit.ApplicationLayer/WritableApplicationService.cs

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

src/DDDToolkit.Core/AggregateRoot.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
using DDDToolkit.Core.Interfaces;
2-
using System.Collections.Generic;
32

43
namespace DDDToolkit.Core
54
{
5+
/// <summary>
6+
/// <para>
7+
/// A semantic difference from <see cref="IEntity{T}"/>, the
8+
/// aggregate root represents an entity that is resposible for
9+
/// handling all interactions with the aggregate.
10+
/// </para>
11+
/// <para>
12+
/// Behaviour is identical to <see cref="IEntity{T}"/>, and
13+
/// equality is defined by the two aggregate roots being of the
14+
/// same type, with Ids that are equal.
15+
/// </para>
16+
/// <para>
17+
/// In addition to the behaviour of <see cref="IEntity{T}"/>, the
18+
/// aggregate root should be used by repositories, services, etc to
19+
/// help control the points of interactions with entities.
20+
/// </para>
21+
/// </summary>
22+
/// <typeparam name="T">The type of the Id for the Aggregate Root.</typeparam>
623
public abstract class AggregateRoot<T> : Entity<T>, IAggregateRoot<T>
724
{
825
}

src/DDDToolkit.Core/DDDToolkit.Core.csproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@
1313
<RepositoryUrl>https://github.com/codepb/DDDToolkit</RepositoryUrl>
1414
<PackageTags>DDD, Domain Driven Design, Entity, Aggregate</PackageTags>
1515
<PackageIconUrl>https://raw.githubusercontent.com/codepb/DDDToolkit/master/logo/logo.png</PackageIconUrl>
16-
<Version>2.0.0</Version>
16+
<Version>2.1.0</Version>
17+
</PropertyGroup>
18+
19+
<PropertyGroup>
20+
<DocumentationFile>C:\Users\paulj\source\repos\DDDToolkit\src\DDDToolkit.Core\DDDToolkit.Core.xml</DocumentationFile>
1721
</PropertyGroup>
1822

1923
<ItemGroup>
20-
<None Include="..\..\LICENSE" Pack="true" PackagePath=""/>
24+
<None Include="..\..\LICENSE" Pack="true" PackagePath="" />
2125
</ItemGroup>
2226

2327
<ItemGroup>

0 commit comments

Comments
 (0)