Skip to content

App service improvements #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Mar 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified logo/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentQueries" Version="1.1.1" />
<PackageReference Include="FluentQueries" Version="1.3.2" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentQueries" Version="1.1.1" />
<PackageReference Include="FluentQueries" Version="1.3.2" />
<PackageReference Include="Microsoft.AspNetCore.All" />
</ItemGroup>

Expand Down
37 changes: 36 additions & 1 deletion src/DDDToolkit.ApplicationLayer/ApplicationService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
using DDDToolkit.ApplicationLayer.Transactions;
using DDDToolkit.ApplicationLayer.Repositories;
using DDDToolkit.ApplicationLayer.Transactions;
using DDDToolkit.Core.Interfaces;
using FluentQueries;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace DDDToolkit.ApplicationLayer
Expand All @@ -16,6 +21,36 @@ protected Task<ITransaction> BeginTransaction()
{
return _unitOfWork.BeginTransaction();
}
protected Task<IReadOnlyCollection<T>> Query<T, TId>(IQuery<T> query, QueryOptions queryOptions = null, CancellationToken cancellationToken = default(CancellationToken)) where T : class, IAggregateRoot<TId>
{
return ReadableRepository<T, TId>().Query(query, queryOptions, cancellationToken);
}

protected Task<T> FirstOrDefault<T, TId>(IQuery<T> query, string[] onlyIncludePaths = null, CancellationToken cancellationToken = default(CancellationToken)) where T : class, IAggregateRoot<TId>
{
return ReadableRepository<T, TId>().FirstOrDefault(query, onlyIncludePaths, cancellationToken);
}

protected Task Add<T, TId>(T entity) where T : class, IAggregateRoot<TId>
{
return WritableRepository<T, TId>().Add(entity);
}

protected Task Update<T, TId>(T entity) where T : class, IAggregateRoot<TId>
{
return WritableRepository<T, TId>().Update(entity);
}

protected Task Remove<T, TId>(TId id) where T : class, IAggregateRoot<TId>
{
return WritableRepository<T, TId>().Remove(id);
}

protected IRepository<T, TId> Repository<T, TId>() where T : class, IAggregateRoot<TId> => _unitOfWork.Repository<T, TId>();

protected IReadableRepository<T, TId> ReadableRepository<T, TId>() where T : class, IAggregateRoot<TId> => _unitOfWork.ReadableRepository<T, TId>();

protected IWritableRepository<T, TId> WritableRepository<T, TId>() where T : class, IAggregateRoot<TId> => _unitOfWork.WritableRepository<T, TId>();

protected Task SaveChanges()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
<RepositoryUrl>https://github.com/codepb/DDDToolkit</RepositoryUrl>
<PackageTags>DDD, Domain Driven Design, Application Layer</PackageTags>
<PackageIconUrl>https://raw.githubusercontent.com/codepb/DDDToolkit/master/logo/logo.png</PackageIconUrl>
<Version>2.0.0</Version>
<Version>2.1.0</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\LICENSE" Pack="true" PackagePath=""/>
<None Include="..\..\LICENSE" Pack="true" PackagePath="" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentQueries" Version="1.1.1" />
<PackageReference Include="FluentQueries" Version="1.3.2" />
</ItemGroup>

<ItemGroup>
Expand Down
18 changes: 0 additions & 18 deletions src/DDDToolkit.ApplicationLayer/ReadableApplicationService.cs

This file was deleted.

18 changes: 0 additions & 18 deletions src/DDDToolkit.ApplicationLayer/WritableApplicationService.cs

This file was deleted.

19 changes: 18 additions & 1 deletion src/DDDToolkit.Core/AggregateRoot.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
using DDDToolkit.Core.Interfaces;
using System.Collections.Generic;

namespace DDDToolkit.Core
{
/// <summary>
/// <para>
/// A semantic difference from <see cref="IEntity{T}"/>, the
/// aggregate root represents an entity that is resposible for
/// handling all interactions with the aggregate.
/// </para>
/// <para>
/// Behaviour is identical to <see cref="IEntity{T}"/>, and
/// equality is defined by the two aggregate roots being of the
/// same type, with Ids that are equal.
/// </para>
/// <para>
/// In addition to the behaviour of <see cref="IEntity{T}"/>, the
/// aggregate root should be used by repositories, services, etc to
/// help control the points of interactions with entities.
/// </para>
/// </summary>
/// <typeparam name="T">The type of the Id for the Aggregate Root.</typeparam>
public abstract class AggregateRoot<T> : Entity<T>, IAggregateRoot<T>
{
}
Expand Down
8 changes: 6 additions & 2 deletions src/DDDToolkit.Core/DDDToolkit.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@
<RepositoryUrl>https://github.com/codepb/DDDToolkit</RepositoryUrl>
<PackageTags>DDD, Domain Driven Design, Entity, Aggregate</PackageTags>
<PackageIconUrl>https://raw.githubusercontent.com/codepb/DDDToolkit/master/logo/logo.png</PackageIconUrl>
<Version>2.0.0</Version>
<Version>2.1.0</Version>
</PropertyGroup>

<PropertyGroup>
<DocumentationFile>C:\Users\paulj\source\repos\DDDToolkit\src\DDDToolkit.Core\DDDToolkit.Core.xml</DocumentationFile>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\LICENSE" Pack="true" PackagePath=""/>
<None Include="..\..\LICENSE" Pack="true" PackagePath="" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading