| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using GreenTree.Nachtragsmanagement.Core.Domain.Config;
- using GreenTree.Nachtragsmanagement.Core.Domain.Misc;
- namespace GreenTree.Nachtragsmanagement.Core.Domain.User
- {
- public class User : BaseEntity
- {
- #region Fields
- /// <summary>
- /// Current role
- /// </summary>
- private Role _currentRole;
- /// <summary>
- /// Rolelist
- /// </summary>
- private ICollection<Role> _roles;
- /// <summary>
- /// Notificationlist
- /// </summary>
- private ICollection<MailNotification> _mailNotifications;
- /// <summary>
- /// Configitemlist
- /// </summary>
- private ICollection<UserConfigItem> _userConfigItems;
- #endregion
- /// <summary>
- /// CustomNumber for identification
- /// </summary>
- public string CustomNumber { get; set; }
- /// <summary>
- /// Forename
- /// </summary>
- public string Forename { get; set; }
- /// <summary>
- /// Lastname
- /// </summary>
- public string Lastname { get; set; }
- /// <summary>
- /// Mail-Address
- /// </summary>
- public string MailAddress { get; set; }
- /// <summary>
- /// Password
- /// </summary>
- public string Password { get; set; }
- /// <summary>
- /// The role the current user is using
- /// </summary>
- public Role CurrentRole
- {
- get
- {
- return _currentRole;
- }
- set
- {
- _currentRole = value;
- }
- }
- /// <summary>
- /// Determines if there are changes to the user settings
- /// </summary>
- public bool? IsChanged { get; set; }
- /// <summary>
- /// Roles the user have
- /// </summary>
- public virtual ICollection<Role> Roles
- {
- get { return _roles ?? (_roles = new List<Role>()); }
- protected set { _roles = value; }
- }
- /// <summary>
- /// MailNotification related to the user
- /// </summary>
- public virtual ICollection<MailNotification> MailNotifications
- {
- get { return _mailNotifications ?? ( _mailNotifications = new List<MailNotification>()); }
- protected set { _mailNotifications = value; }
- }
- /// <summary>
- /// UserConfigItems related to the user
- /// </summary>
- public virtual ICollection<UserConfigItem> UserConfigItems
- {
- get { return _userConfigItems ?? ( _userConfigItems = new List<UserConfigItem>()); }
- protected set { _userConfigItems = value; }
- }
- #region Helper
- /// <summary>
- /// Adds missing roles and removes not selected roles
- /// </summary>
- /// <param name="roles">User roles.</param>
- public void SetRoles(ICollection<Role> roles)
- {
- Roles = roles;
- }
- /// <summary>
- /// Determines if the user is member of role which owns a specific function
- /// </summary>
- /// <param name="functionName">The name of the function.</param>
- public bool HasFunction(string functionName)
- {
- if (String.IsNullOrEmpty(functionName))
- return false;
- return
- CurrentRole.Functions
- .Any(f => f.Name == functionName);
- }
- #endregion
- }
- }
|