diff --git a/Build/Build.cs b/Build/Build.cs index 1e0d56e8..a4c7e9b9 100644 --- a/Build/Build.cs +++ b/Build/Build.cs @@ -135,7 +135,7 @@ protected override void OnBuildInitialized() { Log.Information("Generating NuGet packages for projects in solution"); int commitNum = 0; - string NuGetVersionCustom = "2.1.1"; + string NuGetVersionCustom = "2.1.1.1"; //if it's not a tagged release - append the commit number to the package version diff --git a/Src/RCommon.Models/Commands/CommandResult.cs b/Src/RCommon.Models/Commands/CommandResult.cs index 0b69d5b3..2a9aa856 100644 --- a/Src/RCommon.Models/Commands/CommandResult.cs +++ b/Src/RCommon.Models/Commands/CommandResult.cs @@ -2,14 +2,17 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; namespace RCommon.Models.Commands { + [DataContract] public record CommandResult : ICommandResult where TExecutionResult : IExecutionResult { + [DataMember] public TExecutionResult Result { get; } public CommandResult(TExecutionResult result) diff --git a/Src/RCommon.Models/ExecutionResults/ExecutionResult.cs b/Src/RCommon.Models/ExecutionResults/ExecutionResult.cs index 87e827e5..d3bfef80 100644 --- a/Src/RCommon.Models/ExecutionResults/ExecutionResult.cs +++ b/Src/RCommon.Models/ExecutionResults/ExecutionResult.cs @@ -23,9 +23,11 @@ using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; namespace RCommon.Models.ExecutionResults { + [DataContract] public abstract record ExecutionResult : IExecutionResult { private static readonly IExecutionResult SuccessResult = new SuccessExecutionResult(); @@ -36,6 +38,7 @@ public abstract record ExecutionResult : IExecutionResult public static IExecutionResult Failed(IEnumerable errors) => new FailedExecutionResult(errors); public static IExecutionResult Failed(params string[] errors) => new FailedExecutionResult(errors); + [DataMember] public abstract bool IsSuccess { get; } public override string ToString() diff --git a/Src/RCommon.Models/ExecutionResults/FailedExecutionResult.cs b/Src/RCommon.Models/ExecutionResults/FailedExecutionResult.cs index de169313..106f4815 100644 --- a/Src/RCommon.Models/ExecutionResults/FailedExecutionResult.cs +++ b/Src/RCommon.Models/ExecutionResults/FailedExecutionResult.cs @@ -23,9 +23,11 @@ using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; namespace RCommon.Models.ExecutionResults { + [DataContract] public record FailedExecutionResult : ExecutionResult { public IReadOnlyCollection Errors { get; } @@ -36,6 +38,7 @@ public FailedExecutionResult( Errors = (errors ?? Enumerable.Empty()).ToList(); } + [DataMember] public override bool IsSuccess { get; } = false; public override string ToString() diff --git a/Src/RCommon.Models/ExecutionResults/SuccessExecutionResult.cs b/Src/RCommon.Models/ExecutionResults/SuccessExecutionResult.cs index 13d7604c..0a206cfb 100644 --- a/Src/RCommon.Models/ExecutionResults/SuccessExecutionResult.cs +++ b/Src/RCommon.Models/ExecutionResults/SuccessExecutionResult.cs @@ -21,10 +21,14 @@ // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +using System.Runtime.Serialization; + namespace RCommon.Models.ExecutionResults { + [DataContract] public record SuccessExecutionResult : ExecutionResult { + [DataMember] public override bool IsSuccess { get; } = true; public override string ToString() diff --git a/Src/RCommon.Models/PaginatedListModel.cs b/Src/RCommon.Models/PaginatedListModel.cs index 45a05d04..5260f34f 100644 --- a/Src/RCommon.Models/PaginatedListModel.cs +++ b/Src/RCommon.Models/PaginatedListModel.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; +using System.Runtime.Serialization; using System.Text; using RCommon.Collections; @@ -11,6 +12,7 @@ namespace RCommon.Models /// Represents a Data Transfer Object (DTO) that is typically used to encapsulate a PaginatedList so that it can be /// delivered to the application layer. This should be an immutable object. /// + [DataContract] public abstract record PaginatedListModel : IModel where TSource : class where TOut : class @@ -131,18 +133,28 @@ protected void PaginateList(IPaginatedList source, PaginatedListRequest public virtual Expression> SortExpression { get => _sortExpression; set => _sortExpression = value; } + [DataMember] public List Items { get; set; } + [DataMember] public int? PageSize { get; set; } + + [DataMember] public int PageNumber { get; set; } + [DataMember] public int TotalPages { get; set; } + + [DataMember] public int TotalCount { get; set; } + [DataMember] public string SortBy { get; set; } + [DataMember] public SortDirectionEnum SortDirection { get; set; } + [DataMember] public bool HasPreviousPage { get @@ -151,6 +163,7 @@ public bool HasPreviousPage } } + [DataMember] public bool HasNextPage { get @@ -164,6 +177,7 @@ public bool HasNextPage /// Represents a Data Transfer Object (DTO) that is typically used to encapsulate a PaginatedList so that it can be /// delivered to the application layer. This should be an immutable object. /// + [DataContract] public abstract record PaginatedListModel : IModel where TSource : class { @@ -281,18 +295,28 @@ protected void PaginateList(IPaginatedList source, PaginatedListRequest public virtual Expression> SortExpression { get => _sortExpression; set => _sortExpression = value; } + [DataMember] public List Items { get; set; } + [DataMember] public int? PageSize { get; set; } + + [DataMember] public int PageNumber { get; set; } + [DataMember] public int TotalPages { get; set; } + + [DataMember] public int TotalCount { get; set; } + [DataMember] public string SortBy { get; set; } + [DataMember] public SortDirectionEnum SortDirection { get; set; } + [DataMember] public bool HasPreviousPage { get @@ -301,6 +325,7 @@ public bool HasPreviousPage } } + [DataMember] public bool HasNextPage { get diff --git a/Src/RCommon.Models/PaginatedListRequest.cs b/Src/RCommon.Models/PaginatedListRequest.cs index f8346e12..ec549a9f 100644 --- a/Src/RCommon.Models/PaginatedListRequest.cs +++ b/Src/RCommon.Models/PaginatedListRequest.cs @@ -14,9 +14,16 @@ public PaginatedListRequest() SortDirection = SortDirectionEnum.None; } + [DataMember] public virtual int PageNumber { get; set; } + + [DataMember] public virtual int? PageSize { get; set; } + + [DataMember] public virtual string SortBy { get; set; } + + [DataMember] public virtual SortDirectionEnum SortDirection { get; set; } } } diff --git a/Src/RCommon.Models/SearchPaginatedListRequest.cs b/Src/RCommon.Models/SearchPaginatedListRequest.cs index 9e6f2748..3935b216 100644 --- a/Src/RCommon.Models/SearchPaginatedListRequest.cs +++ b/Src/RCommon.Models/SearchPaginatedListRequest.cs @@ -1,17 +1,21 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; namespace RCommon.Models { + [DataContract] public record SearchPaginatedListRequest : PaginatedListRequest, ISearchPaginatedListRequest { public SearchPaginatedListRequest() { } + + [DataMember] public string SearchString { get; set; } } } diff --git a/Src/RCommon.Models/SortDirectionEnum.cs b/Src/RCommon.Models/SortDirectionEnum.cs index 6ce88084..24a82cc2 100644 --- a/Src/RCommon.Models/SortDirectionEnum.cs +++ b/Src/RCommon.Models/SortDirectionEnum.cs @@ -1,11 +1,13 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; namespace RCommon.Models { + [DataContract] public enum SortDirectionEnum : byte { Ascending = 1,