4 namespace CPE.App.Web.Connect {
7 /// Represents a principal-info object returned from Connect.
9 public class PrincipalInfo {
12 /// The ID of the account the principal belongs to.
14 public int AccountId { get; private set; }
17 /// The date the account was disabled. If the account is active, then the value will be null.
19 public DateTime? Disabled { get; private set; }
22 /// The ID of the principal.
24 public int PrincipalId { get; private set; }
27 /// The principal’s login ID on Connect Enterprise. Can be the same as an e-mail address.
29 public string Login { get; private set; }
32 /// For a user, the e-mail address.
34 public string Email { get; private set; }
37 /// For a user, the full name, concatenated from their first and last name fields.
39 public string Name { get; private set; }
42 /// For a user, the first name.
44 public string FirstName { get; private set; }
47 /// For a user, the last name.
49 public string LastName { get; private set; }
52 public string DisplayName
56 return string.Format("{0} {1}", FirstName, LastName).Trim();
61 /// Initializes the object by parsing the values from the XmlDocument.
63 /// <param name="document">The XmlDocument returned from Connect for this object.</param>
64 public PrincipalInfo(XmlNode document) {
67 XmlNode principal = document.SelectSingleNode("/results/principal");
70 AccountId = int.Parse(principal.Attributes["account-id"].Value);
71 PrincipalId = int.Parse(principal.Attributes["principal-id"].Value);
72 Login = principal.SelectSingleNode("login").InnerText;
73 Name = principal.SelectSingleNode("name").InnerText;
76 FirstName = principal.SelectSingleNode("first-name").InnerText;
84 LastName = principal.SelectSingleNode("last-name").InnerText;
90 Email = principal.SelectSingleNode("email").InnerText;
92 if(principal.Attributes["disabled"].Value != string.Empty)
93 Disabled = DateTime.Parse(principal.Attributes["disabled"].Value);