aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Models/Http/UserController.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-01-30 20:26:52 +0800
committercrupest <crupest@outlook.com>2020-01-30 20:26:52 +0800
commit52acf41e331ddbd66befed4692c804b754ba7d5c (patch)
tree538ceea06640f501d2a950cac813c10561036e4d /Timeline/Models/Http/UserController.cs
parentabde51b167f17301c25e32ae247e7909c0dc9367 (diff)
downloadtimeline-52acf41e331ddbd66befed4692c804b754ba7d5c.tar.gz
timeline-52acf41e331ddbd66befed4692c804b754ba7d5c.tar.bz2
timeline-52acf41e331ddbd66befed4692c804b754ba7d5c.zip
...
Diffstat (limited to 'Timeline/Models/Http/UserController.cs')
-rw-r--r--Timeline/Models/Http/UserController.cs26
1 files changed, 26 insertions, 0 deletions
diff --git a/Timeline/Models/Http/UserController.cs b/Timeline/Models/Http/UserController.cs
index 229ca1e5..e4c95cbd 100644
--- a/Timeline/Models/Http/UserController.cs
+++ b/Timeline/Models/Http/UserController.cs
@@ -1,5 +1,7 @@
+using AutoMapper;
using System.ComponentModel.DataAnnotations;
using Timeline.Models.Validation;
+using Timeline.Services;
namespace Timeline.Models.Http
{
@@ -17,6 +19,21 @@ namespace Timeline.Models.Http
public bool? Administrator { get; set; }
}
+ public class CreateUserRequest
+ {
+ [Required, Username]
+ public string Username { get; set; } = default!;
+
+ [Required, MinLength(1)]
+ public string Password { get; set; } = default!;
+
+ [Required]
+ public bool? Administrator { get; set; }
+
+ [Nickname]
+ public string? Nickname { get; set; }
+ }
+
public class ChangePasswordRequest
{
[Required(AllowEmptyStrings = false)]
@@ -24,4 +41,13 @@ namespace Timeline.Models.Http
[Required(AllowEmptyStrings = false)]
public string NewPassword { get; set; } = default!;
}
+
+ public class UserControllerAutoMapperProfile : Profile
+ {
+ public UserControllerAutoMapperProfile()
+ {
+ CreateMap<UserPatchRequest, User>(MemberList.Source);
+ CreateMap<CreateUserRequest, User>(MemberList.Source);
+ }
+ }
}