/
ApplicationUser.cs
89 lines (74 loc) · 2.58 KB
/
ApplicationUser.cs
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Arch.Domain.Models;
namespace Arch.Domain.Entities
{
public class ApplicationUser : IdentityUser
{
public ApplicationUser()
{
//Architects = new List<Architect>();
Files = new List<File>();
}
[Display(Name = "User Id")]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int DisplayId { get; set; }
[StringLength(4)]
[Display(Name = "Title")]
public string Title { get; set; }
[StringLength(60)]
[Display(Name = "Forename(s)")]
public string FirstName { get; set; }
[StringLength(50)]
[Display(Name = "Surname")]
public string LastName { get; set; }
[Display(Name = "Date of Birth")]
public DateTime? DOB { get; set; }
[NotMapped]
[Display(Name = "Full Name")]
public string FullName {
get {
return AsPerson().FullName;
}
}
// Virtuals (related entities)
public virtual ICollection<File> Files { get; set; }
// public virtual ICollection<Editor> Editors { get; set; }
public Person AsPerson()
{
return new Person {
Title = Title,
FirstName = FirstName,
LastName = LastName,
};
}
public string UserId()
{
return DisplayId.ToString();
}
public string DocFolder()
{
string docRoot = System.Configuration.ConfigurationManager.AppSettings["Settings.Site.DocFolder"];
return string.Format(@"{0}\Users\{1}", docRoot, DisplayId);
}
//public bool HasMaxReferees()
//{
// return (Architects.Where(x => !x.OptedOutDate.HasValue).Count() >= 2);
//}
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
}
}