User.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using GreenTree.Nachtragsmanagement.Core.Domain.Misc;
  7. namespace GreenTree.Nachtragsmanagement.Core.Domain.User
  8. {
  9. public class User : BaseEntity
  10. {
  11. #region Fields
  12. /// <summary>
  13. /// Rolelist
  14. /// </summary>
  15. private ICollection<Role> _roles;
  16. /// <summary>
  17. /// Notificationlist
  18. /// </summary>
  19. private ICollection<MailNotification> _mailNotifications;
  20. #endregion
  21. /// <summary>
  22. /// CustomNumber for identification
  23. /// </summary>
  24. public string CustomNumber { get; set; }
  25. /// <summary>
  26. /// Forename
  27. /// </summary>
  28. public string Forename { get; set; }
  29. /// <summary>
  30. /// Lastname
  31. /// </summary>
  32. public string Lastname { get; set; }
  33. /// <summary>
  34. /// Mail-Address
  35. /// </summary>
  36. public string MailAddress { get; set; }
  37. /// <summary>
  38. /// Password
  39. /// </summary>
  40. public string Password { get; set; }
  41. /// <summary>
  42. /// The role the current user is using
  43. /// </summary>
  44. public Role CurrentRole { get; set; }
  45. /// <summary>
  46. /// Roles the user have
  47. /// </summary>
  48. public virtual ICollection<Role> Roles
  49. {
  50. get { return _roles ?? (_roles = new List<Role>()); }
  51. protected set { _roles = value; }
  52. }
  53. /// <summary>
  54. /// MailNotification related to the user
  55. /// </summary>
  56. public virtual ICollection<MailNotification> MailNotifications
  57. {
  58. get { return _mailNotifications ?? ( _mailNotifications = new List<MailNotification>()); }
  59. protected set { _mailNotifications = value; }
  60. }
  61. #region Helper
  62. /// <summary>
  63. /// Adds missing roles and removes not selected roles
  64. /// </summary>
  65. /// <param name="roles">User roles.</param>
  66. public void SetRoles(ICollection<Role> roles)
  67. {
  68. Roles = roles;
  69. }
  70. #endregion
  71. }
  72. }