From f0870ca427bfe17b771e8a61c51f000e300bd3f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Wed, 14 Mar 2018 14:27:50 +0300 Subject: [PATCH] #233 DTO audited base classes. --- .../Abp/Application/Dtos/AuditedEntityDto.cs | 32 +++++++++++++++ .../Dtos/AuditedEntityWithUserDto.cs | 34 ++++++++++++++++ .../Dtos/CreationAuditedEntityDto.cs | 32 +++++++++++++++ .../Dtos/CreationAuditedEntityWithUserDto.cs | 26 ++++++++++++ .../Volo/Abp/Application/Dtos/EntityDto.cs | 25 +++--------- .../Application/Dtos/FullAuditedEntityDto.cs | 38 ++++++++++++++++++ .../Dtos/FullAuditedEntityWithUserDto.cs | 40 +++++++++++++++++++ .../Dtos/LimitedResultRequestDto.cs | 2 + .../Abp/Application/Dtos/ListResultDto.cs | 2 + 9 files changed, 212 insertions(+), 19 deletions(-) create mode 100644 src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/AuditedEntityDto.cs create mode 100644 src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/AuditedEntityWithUserDto.cs create mode 100644 src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/CreationAuditedEntityDto.cs create mode 100644 src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/CreationAuditedEntityWithUserDto.cs create mode 100644 src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/FullAuditedEntityDto.cs create mode 100644 src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/FullAuditedEntityWithUserDto.cs diff --git a/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/AuditedEntityDto.cs b/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/AuditedEntityDto.cs new file mode 100644 index 0000000000..dc39b34b79 --- /dev/null +++ b/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/AuditedEntityDto.cs @@ -0,0 +1,32 @@ +using System; +using Volo.Abp.Auditing; + +namespace Volo.Abp.Application.Dtos +{ + /// + /// This class can be inherited by DTO classes to implement interface. + /// + [Serializable] + public abstract class AuditedEntityDto : CreationAuditedEntityDto, IAudited + { + /// + public DateTime? LastModificationTime { get; set; } + + /// + public long? LastModifierUserId { get; set; } + } + + /// + /// This class can be inherited by DTO classes to implement interface. + /// + /// Type of primary key + [Serializable] + public abstract class AuditedEntityDto : CreationAuditedEntityDto, IAudited + { + /// + public DateTime? LastModificationTime { get; set; } + + /// + public long? LastModifierUserId { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/AuditedEntityWithUserDto.cs b/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/AuditedEntityWithUserDto.cs new file mode 100644 index 0000000000..d18ce732fd --- /dev/null +++ b/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/AuditedEntityWithUserDto.cs @@ -0,0 +1,34 @@ +using System; +using Volo.Abp.Auditing; + +namespace Volo.Abp.Application.Dtos +{ + /// + /// This class can be inherited by DTO classes to implement interface. + /// + /// Type of the User DTO + [Serializable] + public abstract class AuditedEntityWithUserDto : AuditedEntityDto, IAudited + { + /// + public TUserDto CreatorUser { get; set; } + + /// + public TUserDto LastModifierUser { get; set; } + } + + /// + /// This class can be inherited by DTO classes to implement interface. + /// + /// Type of primary key + /// Type of the User DTO + [Serializable] + public abstract class AuditedEntityWithUserDto : AuditedEntityDto, IAudited + { + /// + public TUserDto CreatorUser { get; set; } + + /// + public TUserDto LastModifierUser { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/CreationAuditedEntityDto.cs b/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/CreationAuditedEntityDto.cs new file mode 100644 index 0000000000..92b3eaaa99 --- /dev/null +++ b/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/CreationAuditedEntityDto.cs @@ -0,0 +1,32 @@ +using System; +using Volo.Abp.Auditing; + +namespace Volo.Abp.Application.Dtos +{ + /// + /// This class can be inherited by DTO classes to implement interface. + /// + [Serializable] + public abstract class CreationAuditedEntityDto : EntityDto, ICreationAudited + { + /// + public DateTime CreationTime { get; set; } + + /// + public long? CreatorUserId { get; set; } + } + + /// + /// This class can be inherited by DTO classes to implement interface. + /// + /// Type of primary key + [Serializable] + public abstract class CreationAuditedEntityDto : EntityDto, ICreationAudited + { + /// + public DateTime CreationTime { get; set; } + + /// + public long? CreatorUserId { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/CreationAuditedEntityWithUserDto.cs b/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/CreationAuditedEntityWithUserDto.cs new file mode 100644 index 0000000000..3986b8da00 --- /dev/null +++ b/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/CreationAuditedEntityWithUserDto.cs @@ -0,0 +1,26 @@ +using System; +using Volo.Abp.Auditing; + +namespace Volo.Abp.Application.Dtos +{ + /// + /// This class can be inherited by DTO classes to implement interface. + /// + /// Type of the User DTO + [Serializable] + public abstract class CreationAuditedEntityWithUserDto : CreationAuditedEntityDto, ICreationAudited + { + public TUserDto CreatorUser { get; set; } + } + + /// + /// This class can be inherited by DTO classes to implement interface. + /// + /// Type of primary key + /// Type of the User DTO + [Serializable] + public abstract class CreationAuditedEntityWithUserDto : CreationAuditedEntityDto, ICreationAudited + { + public TUserDto CreatorUser { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/EntityDto.cs b/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/EntityDto.cs index 76407cf8a5..e86a3f88d1 100644 --- a/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/EntityDto.cs +++ b/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/EntityDto.cs @@ -1,6 +1,9 @@ +using System; + namespace Volo.Abp.Application.Dtos { - public class EntityDto : IEntityDto //TODO: Consider to delete this class + [Serializable] + public abstract class EntityDto : IEntityDto //TODO: Consider to delete this class { public override string ToString() { @@ -8,30 +11,14 @@ namespace Volo.Abp.Application.Dtos } } - public class EntityDto : EntityDto, IEntityDto + [Serializable] + public abstract class EntityDto : EntityDto, IEntityDto { /// /// Id of the entity. /// public TKey Id { get; set; } - /// - /// Creates a new object. - /// - public EntityDto() - { - - } - - /// - /// Creates a new object. - /// - /// Id of the entity - public EntityDto(TKey id) - { - Id = id; - } - public override string ToString() { return $"[DTO: {GetType().Name}] Id = {Id}"; diff --git a/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/FullAuditedEntityDto.cs b/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/FullAuditedEntityDto.cs new file mode 100644 index 0000000000..e13b6130c0 --- /dev/null +++ b/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/FullAuditedEntityDto.cs @@ -0,0 +1,38 @@ +using System; +using Volo.Abp.Auditing; + +namespace Volo.Abp.Application.Dtos +{ + /// + /// This class can be inherited by DTO classes to implement interface. + /// + [Serializable] + public abstract class FullAuditedEntityDto : AuditedEntityDto, IFullAudited + { + /// + public bool IsDeleted { get; set; } + + /// + public long? DeleterUserId { get; set; } + + /// + public DateTime? DeletionTime { get; set; } + } + + /// + /// This class can be inherited by DTO classes to implement interface. + /// + /// Type of primary key + [Serializable] + public abstract class FullAuditedEntityDto : AuditedEntityDto, IFullAudited + { + /// + public bool IsDeleted { get; set; } + + /// + public long? DeleterUserId { get; set; } + + /// + public DateTime? DeletionTime { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/FullAuditedEntityWithUserDto.cs b/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/FullAuditedEntityWithUserDto.cs new file mode 100644 index 0000000000..f3c727e6d9 --- /dev/null +++ b/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/FullAuditedEntityWithUserDto.cs @@ -0,0 +1,40 @@ +using System; +using Volo.Abp.Auditing; + +namespace Volo.Abp.Application.Dtos +{ + /// + /// This class can be inherited by DTO classes to implement interface. + /// + /// Type of the User + [Serializable] + public abstract class FullAuditedEntityWithUserDto : FullAuditedEntityDto, IFullAudited + { + /// + public TUserDto CreatorUser { get; set; } + + /// + public TUserDto LastModifierUser { get; set; } + + /// + public TUserDto DeleterUser { get; set; } + } + + /// + /// This class can be inherited by DTO classes to implement interface. + /// + /// Type of primary key + /// Type of the User + [Serializable] + public abstract class FullAuditedEntityWithUserDto : FullAuditedEntityDto, IFullAudited + { + /// + public TUserDto CreatorUser { get; set; } + + /// + public TUserDto LastModifierUser { get; set; } + + /// + public TUserDto DeleterUser { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/LimitedResultRequestDto.cs b/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/LimitedResultRequestDto.cs index 030901b38a..b3ed6a23cb 100644 --- a/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/LimitedResultRequestDto.cs +++ b/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/LimitedResultRequestDto.cs @@ -1,3 +1,4 @@ +using System; using System.ComponentModel.DataAnnotations; namespace Volo.Abp.Application.Dtos @@ -5,6 +6,7 @@ namespace Volo.Abp.Application.Dtos /// /// Simply implements . /// + [Serializable] public class LimitedResultRequestDto : ILimitedResultRequest { [Range(1, int.MaxValue)] diff --git a/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/ListResultDto.cs b/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/ListResultDto.cs index acdc42c873..6b3c897aa9 100644 --- a/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/ListResultDto.cs +++ b/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Dtos/ListResultDto.cs @@ -1,7 +1,9 @@ +using System; using System.Collections.Generic; namespace Volo.Abp.Application.Dtos { + [Serializable] public class ListResultDto : IListResult { ///