Skip to content

Commit

Permalink
Modified page so that it is immutable
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuck committed Dec 14, 2020
1 parent a041025 commit 5048bce
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 19 deletions.
3 changes: 3 additions & 0 deletions src/YuckQi.Domain.Services/Abstract/ITypeEntityService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ namespace YuckQi.Domain.Services.Abstract
{
public interface ITypeEntityService<T, TKey> where T : TypeEntityBase<TKey> where TKey : struct
{
Task<Result<T>> CreateAsync(T entity);
Task<Result<T>> GetAsync(TKey key);
Task<Result<T>> ModifyAsync(T entity);
Task<Result<Page<T, TKey>>> SearchAsync(TypeSearchCriteria criteria = null);
}
}
2 changes: 1 addition & 1 deletion src/YuckQi.Domain.Services/YuckQi.Domain.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Kevin J Lambert</Authors>
<Version>0.2.2</Version>
<Version>0.3.0</Version>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Kevin J Lambert</Authors>
<Version>0.2.2</Version>
<Version>0.3.0</Version>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/YuckQi.Domain/Application/Abstract/IPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public interface IPage
{
int PageNumber { get; set; }
int PageSize { get; set; }
int PageNumber { get; }
int PageSize { get; }
}
}

This file was deleted.

29 changes: 23 additions & 6 deletions src/YuckQi.Domain/Application/Queries/Results/Page.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,42 @@

namespace YuckQi.Domain.Application.Queries.Results
{
public class Page<TEntity, TKey> : IPage where TEntity : class, IEntity<TKey> where TKey : struct
public class Page : IPage
{
#region Properties

public int PageNumber { get; }
public int PageSize { get; }

#endregion


#region Constructors

public Page(int number, int size)
{
PageNumber = number;
PageSize = size;
}

#endregion
}

public class Page<TEntity, TKey> : Page where TEntity : class, IEntity<TKey> where TKey : struct
{
#region Properties

public IReadOnlyCollection<TEntity> Items { get; }
public int PageNumber { get; set; }
public int PageSize { get; set; }
public int TotalCount { get; }

#endregion


#region Constructors

public Page(IReadOnlyCollection<TEntity> items, int page, int rows, int total)
public Page(IReadOnlyCollection<TEntity> items, int total, int number, int size) : base(number, size)
{
Items = items ?? new List<TEntity>();
PageNumber = page;
PageSize = rows;
TotalCount = total;
}

Expand Down
2 changes: 1 addition & 1 deletion src/YuckQi.Domain/YuckQi.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Kevin J Lambert</Authors>
<Version>0.2.2</Version>
<Version>0.3.0</Version>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>

Expand Down

0 comments on commit 5048bce

Please sign in to comment.