aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Models/UserDetail.cs
blob: 91439c6ac71b51303ab36d26556aa6b01532d94f (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
using Timeline.Entities;

namespace Timeline.Models
{
    public class UserDetail
    {
        public string QQ { get; set; }
        public string EMail { get; set; }
        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)
            };
        }
    }
}