aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Models/UserDetail.cs
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2019-08-22 15:29:03 +0800
committerGitHub <noreply@github.com>2019-08-22 15:29:03 +0800
commit3716d2431de08194d3a107ef640febc47c3ee72a (patch)
treeaf83f8596b4fa78713733c0db6b4b6d1695d0ff0 /Timeline/Models/UserDetail.cs
parenta585c6e35829e9f2b4b0b8ce8c6b395e5ea84f2c (diff)
parent968f9688dd3ff7cae6f66af0e69bb03392311c88 (diff)
downloadtimeline-3716d2431de08194d3a107ef640febc47c3ee72a.tar.gz
timeline-3716d2431de08194d3a107ef640febc47c3ee72a.tar.bz2
timeline-3716d2431de08194d3a107ef640febc47c3ee72a.zip
Merge pull request #48 from crupest/user-details
Add user details.
Diffstat (limited to 'Timeline/Models/UserDetail.cs')
-rw-r--r--Timeline/Models/UserDetail.cs43
1 files changed, 43 insertions, 0 deletions
diff --git a/Timeline/Models/UserDetail.cs b/Timeline/Models/UserDetail.cs
new file mode 100644
index 00000000..86866d8b
--- /dev/null
+++ b/Timeline/Models/UserDetail.cs
@@ -0,0 +1,43 @@
+using System.ComponentModel.DataAnnotations;
+using Timeline.Entities;
+using Timeline.Models.Validation;
+
+namespace Timeline.Models
+{
+ public class UserDetail
+ {
+ [MaxLength(10)]
+ public string Nickname { get; set; }
+
+ [ValidateWith(typeof(UserDetailValidators.QQValidator))]
+ public string QQ { get; set; }
+
+ [ValidateWith(typeof(UserDetailValidators.EMailValidator))]
+ public string EMail { get; set; }
+
+ [ValidateWith(typeof(UserDetailValidators.PhoneNumberValidator))]
+ public string PhoneNumber { get; set; }
+
+ public string Description { get; set; }
+
+ private static string CoerceEmptyToNull(string value)
+ {
+ if (string.IsNullOrEmpty(value))
+ return null;
+ else
+ return value;
+ }
+
+ public static UserDetail From(UserDetailEntity entity)
+ {
+ return new UserDetail
+ {
+ Nickname = CoerceEmptyToNull(entity.Nickname),
+ QQ = CoerceEmptyToNull(entity.QQ),
+ EMail = CoerceEmptyToNull(entity.EMail),
+ PhoneNumber = CoerceEmptyToNull(entity.PhoneNumber),
+ Description = CoerceEmptyToNull(entity.Description)
+ };
+ }
+ }
+}