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 95c55174ad..eb646c5ceb 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 @@ namespace Volo.Abp.Application.Dtos 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 6b3c897aa9..0dc9c56568 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 @@ namespace Volo.Abp.Application.Dtos /// public ListResultDto() { - + } /// @@ -31,4 +32,33 @@ namespace Volo.Abp.Application.Dtos 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 4f8d843046..1e87a6574a 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 @@ namespace Volo.Abp.Application.Dtos { 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 b10d64211a..66348fc95d 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 @@ namespace Volo.Abp.Application.Dtos 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 e028dd3f8d..6a05cceede 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 @@ namespace Volo.Abp.Application.Dtos [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; } + } +}