diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/LimitedResultRequestDto.cs b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/LimitedResultRequestDto.cs index 95c55174ad0..eb646c5cebe 100644 --- a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/LimitedResultRequestDto.cs +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/LimitedResultRequestDto.cs @@ -39,14 +39,62 @@ public virtual IEnumerable Validate(ValidationContext validati yield return new ValidationResult( localizer[ - "MaxResultCountExceededExceptionMessage", + "MaxResultCountExceededExceptionMessage", nameof(MaxResultCount), - MaxMaxResultCount, - typeof(LimitedResultRequestDto).FullName, + MaxMaxResultCount, + typeof(LimitedResultRequestDto).FullName, nameof(MaxMaxResultCount) ], new[] { nameof(MaxResultCount) }); } } } -} \ No newline at end of file + + /// + /// Simply implements . + /// + [Serializable] + public class ExtensibleLimitedResultRequestDto : ExtensibleEntityDto, ILimitedResultRequest, IValidatableObject + { + /// + /// Default value: 10. + /// + public static int DefaultMaxResultCount { get; set; } = 10; + + /// + /// Maximum possible value of the . + /// Default value: 1,000. + /// + public static int MaxMaxResultCount { get; set; } = 1000; + + /// + /// Maximum result count should be returned. + /// This is generally used to limit result count on paging. + /// + [Range(1, int.MaxValue)] + public virtual int MaxResultCount { get; set; } = DefaultMaxResultCount; + + public override IEnumerable Validate(ValidationContext validationContext) + { + foreach(var result in base.Validate(validationContext)) + { + yield return result; + } + + if (MaxResultCount > MaxMaxResultCount) + { + var localizer = validationContext.GetRequiredService>(); + + yield return new ValidationResult( + localizer[ + "MaxResultCountExceededExceptionMessage", + nameof(MaxResultCount), + MaxMaxResultCount, + typeof(ExtensibleLimitedResultRequestDto).FullName, + nameof(MaxMaxResultCount) + ], + new[] { nameof(MaxResultCount) }); + } + } + } +} diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ListResultDto.cs b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ListResultDto.cs index 6b3c897aa95..0dc9c565685 100644 --- a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ListResultDto.cs +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ListResultDto.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Volo.Abp.ObjectExtending; namespace Volo.Abp.Application.Dtos { @@ -19,7 +20,7 @@ public IReadOnlyList Items /// public ListResultDto() { - + } /// @@ -31,4 +32,33 @@ public ListResultDto(IReadOnlyList items) Items = items; } } -} \ No newline at end of file + + [Serializable] + public class ExtensibleListResultDto : ExtensibleObject, IListResult + { + /// + public IReadOnlyList Items + { + get { return _items ?? (_items = new List()); } + set { _items = value; } + } + private IReadOnlyList _items; + + /// + /// Creates a new object. + /// + public ExtensibleListResultDto() + { + + } + + /// + /// Creates a new object. + /// + /// List of items + public ExtensibleListResultDto(IReadOnlyList items) + { + Items = items; + } + } +} diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedAndSortedResultRequestDto.cs b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedAndSortedResultRequestDto.cs index 4f8d8430468..1e87a6574a6 100644 --- a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedAndSortedResultRequestDto.cs +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedAndSortedResultRequestDto.cs @@ -10,4 +10,13 @@ public class PagedAndSortedResultRequestDto : PagedResultRequestDto, IPagedAndSo { public virtual string Sorting { get; set; } } -} \ No newline at end of file + + /// + /// Simply implements . + /// + [Serializable] + public class ExtensiblePagedAndSortedResultRequestDto : ExtensiblePagedResultRequestDto, IPagedAndSortedResultRequest + { + public virtual string Sorting { get; set; } + } +} diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedResultDto.cs b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedResultDto.cs index b10d64211ae..66348fc95d5 100644 --- a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedResultDto.cs +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedResultDto.cs @@ -32,4 +32,34 @@ public PagedResultDto(long totalCount, IReadOnlyList items) TotalCount = totalCount; } } -} \ No newline at end of file + + /// + /// Implements . + /// + /// Type of the items in the list + [Serializable] + public class ExtensiblePagedResultDto : ExtensibleListResultDto, IPagedResult + { + /// + public long TotalCount { get; set; } //TODO: Can be a long value..? + + /// + /// Creates a new object. + /// + public ExtensiblePagedResultDto() + { + + } + + /// + /// Creates a new object. + /// + /// Total count of Items + /// List of items in current page + public ExtensiblePagedResultDto(long totalCount, IReadOnlyList items) + : base(items) + { + TotalCount = totalCount; + } + } +} diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedResultRequestDto.cs b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedResultRequestDto.cs index e028dd3f8d1..6a05cceede9 100644 --- a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedResultRequestDto.cs +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedResultRequestDto.cs @@ -12,4 +12,14 @@ public class PagedResultRequestDto : LimitedResultRequestDto, IPagedResultReques [Range(0, int.MaxValue)] public virtual int SkipCount { get; set; } } -} \ No newline at end of file + + /// + /// Simply implements . + /// + [Serializable] + public class ExtensiblePagedResultRequestDto : ExtensibleLimitedResultRequestDto, IPagedResultRequest + { + [Range(0, int.MaxValue)] + public virtual int SkipCount { get; set; } + } +}