Browse Source

DTO AutoMap attributes

HOME 2 years ago
parent
commit
0fb50de1a2

+ 2 - 0
VCommonCoreExample/AppServices/System/Roles/Dto/RoleCreateInput.cs

@@ -1,8 +1,10 @@
 using System.ComponentModel.DataAnnotations;
 using VCommon.VAutoMapper;
+using VCommonCoreExample.Entity;
 
 namespace VCommonCoreExample.AppServices.System.Roles.Dto
 {
+    [AutoMapTo(typeof(Role))]
     public class RoleCreateInput
     {
         [Required]

+ 2 - 0
VCommonCoreExample/AppServices/System/Roles/Dto/RoleDto.cs

@@ -1,8 +1,10 @@
 using VCommon.VApplication.Dto;
 using VCommon.VAutoMapper;
+using VCommonCoreExample.Entity;
 
 namespace VCommonCoreExample.AppServices.System.Roles.Dto
 {
+    [AutoMapFrom(typeof(Role))]
     public class RoleDto : EntityDto, IHaveName
     {
         public string Name { get; set; }

+ 3 - 0
VCommonCoreExample/AppServices/System/Roles/Dto/RoleUpdateInput.cs

@@ -1,8 +1,11 @@
 using System;
 using VCommon.VApplication.Dto;
+using VCommon.VAutoMapper;
+using VCommonCoreExample.Entity;
 
 namespace VCommonCoreExample.AppServices.System.Roles.Dto
 {
+    [AutoMapTo(typeof(Role))]
     public class RoleUpdateInput : RoleCreateInput, IEntityDto
     {
         public Guid Id { get; set; }

+ 0 - 93
VCommonCoreExample/AppServices/System/Users/Dto/Dto.cs

@@ -1,93 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using VCommon.VApplication.Auditing.DataAnnotations;
-using VCommon.VApplication.Dto;
-using VCommon.VAutoMapper;
-using VCommonCoreExample.Entity;
-
-namespace VCommonCoreExample.AppServices.System.Users.Dto
-{
-    public class UserListRequest : PagedRequest, IStringSearchFilter, IPassiveFilter
-    {
-        public string Search { get; set; }
-        public bool? IsEnable { get; set; }
-        public DateTimeRange CreateOn { get; set; }
-    }
-
-    [AutoMapFrom(typeof(User))]
-    public class UserDto : EntityDto, IHaveName
-    {
-        [AutoMapJsonConvert()]
-        public Guid[] Roles { get; set; }
-
-        public string Name { get; set; }
-
-        public string LoginName { get; set; }
-
-        public bool IsEnable { get; set; }
-    }
-
-    public class UserListOutput : IPagedResult<UserDto>
-    {
-        public IReadOnlyCollection<NamedEntityDto> AvailableRoles { get; set; }
-
-        public UserListOutput(int totalRecord, IReadOnlyList<UserDto> items)
-        {
-            TotalRecord = totalRecord;
-            Items = items;
-        }
-
-        public int TotalRecord { get; }
-
-        [SimplifyAuditingLog]
-        public IReadOnlyList<UserDto> Items { get; }
-    }
-
-    public class UserFormPrepOutput
-    {
-        public UserDto Output { get; set; }
-
-        public IReadOnlyCollection<NamedEntityDto> AvailableRoles { get; }
-
-        public UserFormPrepOutput(IReadOnlyCollection<NamedEntityDto> availableRoles)
-        {
-            AvailableRoles = availableRoles;
-        }
-    }
-
-    public class UserCreateInput
-    {
-        [Required]
-        [AutoMapJsonConvert]
-        public Guid[] Roles { get; set; }
-
-        [Required]
-        public string Name { get; set; }
-
-        [Required]
-        public string LoginName { get; set; }
-
-        [Required]
-        public string Password { get; set; }
-
-        public bool IsEnable { get; set; }
-    }
-
-    public class UserUpdateInput : EntityDto
-    {
-        [Required]
-        [AutoMapJsonConvert]
-        public Guid[] Roles { get; set; }
-
-        [Required]
-        public string Name { get; set; }
-
-        [Required]
-        public string LoginName { get; set; }
-
-        public string Password { get; set; }
-
-        public bool IsEnable { get; set; }
-    }
-}

+ 26 - 0
VCommonCoreExample/AppServices/System/Users/Dto/UserCreateInput.cs

@@ -0,0 +1,26 @@
+using System;
+using System.ComponentModel.DataAnnotations;
+using VCommon.VAutoMapper;
+using VCommonCoreExample.Entity;
+
+namespace VCommonCoreExample.AppServices.System.Users.Dto
+{
+    [AutoMapTo(typeof(User))]
+    public class UserCreateInput
+    {
+        [Required]
+        [AutoMapJsonConvert]
+        public Guid[] Roles { get; set; }
+
+        [Required]
+        public string Name { get; set; }
+
+        [Required]
+        public string LoginName { get; set; }
+
+        [Required]
+        public string Password { get; set; }
+
+        public bool IsEnable { get; set; }
+    }
+}

+ 20 - 0
VCommonCoreExample/AppServices/System/Users/Dto/UserDto.cs

@@ -0,0 +1,20 @@
+using System;
+using VCommon.VApplication.Dto;
+using VCommon.VAutoMapper;
+using VCommonCoreExample.Entity;
+
+namespace VCommonCoreExample.AppServices.System.Users.Dto
+{
+    [AutoMapFrom(typeof(User))]
+    public class UserDto : EntityDto, IHaveName
+    {
+        [AutoMapJsonConvert()]
+        public Guid[] Roles { get; set; }
+
+        public string Name { get; set; }
+
+        public string LoginName { get; set; }
+
+        public bool IsEnable { get; set; }
+    }
+}

+ 17 - 0
VCommonCoreExample/AppServices/System/Users/Dto/UserFormPrepOutput.cs

@@ -0,0 +1,17 @@
+using System.Collections.Generic;
+using VCommon.VApplication.Dto;
+
+namespace VCommonCoreExample.AppServices.System.Users.Dto
+{
+    public class UserFormPrepOutput
+    {
+        public UserDto Output { get; set; }
+
+        public IReadOnlyCollection<NamedEntityDto> AvailableRoles { get; }
+
+        public UserFormPrepOutput(IReadOnlyCollection<NamedEntityDto> availableRoles)
+        {
+            AvailableRoles = availableRoles;
+        }
+    }
+}

+ 22 - 0
VCommonCoreExample/AppServices/System/Users/Dto/UserListOutput.cs

@@ -0,0 +1,22 @@
+using System.Collections.Generic;
+using VCommon.VApplication.Auditing.DataAnnotations;
+using VCommon.VApplication.Dto;
+
+namespace VCommonCoreExample.AppServices.System.Users.Dto
+{
+    public class UserListOutput : IPagedResult<UserDto>
+    {
+        public IReadOnlyCollection<NamedEntityDto> AvailableRoles { get; set; }
+
+        public UserListOutput(int totalRecord, IReadOnlyList<UserDto> items)
+        {
+            TotalRecord = totalRecord;
+            Items = items;
+        }
+
+        public int TotalRecord { get; }
+
+        [SimplifyAuditingLog]
+        public IReadOnlyList<UserDto> Items { get; }
+    }
+}

+ 11 - 0
VCommonCoreExample/AppServices/System/Users/Dto/UserListRequest.cs

@@ -0,0 +1,11 @@
+using VCommon.VApplication.Dto;
+
+namespace VCommonCoreExample.AppServices.System.Users.Dto
+{
+    public class UserListRequest : PagedRequest, IStringSearchFilter, IPassiveFilter
+    {
+        public string Search { get; set; }
+        public bool? IsEnable { get; set; }
+        public DateTimeRange CreateOn { get; set; }
+    }
+}

+ 26 - 0
VCommonCoreExample/AppServices/System/Users/Dto/UserUpdateInput.cs

@@ -0,0 +1,26 @@
+using System;
+using System.ComponentModel.DataAnnotations;
+using VCommon.VApplication.Dto;
+using VCommon.VAutoMapper;
+using VCommonCoreExample.Entity;
+
+namespace VCommonCoreExample.AppServices.System.Users.Dto
+{
+    [AutoMapTo(typeof(User))]
+    public class UserUpdateInput : EntityDto
+    {
+        [Required]
+        [AutoMapJsonConvert]
+        public Guid[] Roles { get; set; }
+
+        [Required]
+        public string Name { get; set; }
+
+        [Required]
+        public string LoginName { get; set; }
+
+        public string Password { get; set; }
+
+        public bool IsEnable { get; set; }
+    }
+}

+ 0 - 1
VCommonCoreExample/VCommonCoreExample.csproj

@@ -22,7 +22,6 @@
   </ItemGroup>
 
   <ItemGroup>
-    <Folder Include="AppServices\System\Organizations\" />
     <Folder Include="Migrations\" />
   </ItemGroup>