blob: 4af884507b304aa31855543bb5f4a7ffc9cf3ac5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
using Timeline.Entities;
using Timeline.Models.Validation;
namespace Timeline.Models
{
public class UserDetail
{
[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
{
QQ = CoerceEmptyToNull(entity.QQ),
EMail = CoerceEmptyToNull(entity.EMail),
PhoneNumber = CoerceEmptyToNull(entity.PhoneNumber),
Description = CoerceEmptyToNull(entity.Description)
};
}
}
}
|