using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using FoodsharingSiegen.Contracts.Enums; using FoodsharingSiegen.Contracts.Helper; namespace FoodsharingSiegen.Contracts.Entity { /// /// The user class (a. beging, 06.04.2022) /// public class User { #region Public Properties /// /// Gets or sets the value of the created (ab) /// public DateTime Created { get; set; } /// /// Gets or sets the value of the encrypted password (ab) /// public string EncryptedPassword { get; set; } /// /// Gets or sets the value of the force logout (ab) /// public bool ForceLogout { get; set; } /// /// Gets or sets the value of the groups (ab) /// public string Groups { get; set; } /// /// Gets or sets the value of the groups list (ab) /// [NotMapped] public List GroupsList { get { if (string.IsNullOrWhiteSpace(Groups)) return new List(); var stringList = Groups.Split(","); var enumList = stringList.Where(x => !string.IsNullOrWhiteSpace(x)).Select(Enum.Parse).ToList(); return enumList; } set => Groups = string.Join(",", value); } /// /// Gets or sets the value of the id (ab) /// [Key] public Guid Id { get; set; } /// /// Gets or sets the value of the interactions (ab) /// public IList Interactions { get; set; } /// /// Gets or sets the value of the mail (ab) /// public string Mail { get; set; } /// /// Gets or sets the value of the memo (ab) /// public string? Memo { get; set; } /// /// Gets or sets the value of the name (ab) /// public string Name { get; set; } /// /// Gets or sets the value of the network (ab) /// public FsNetworkType Network { get; set; } /// /// Gets the value of the network link (ab) /// [NotMapped] public string NetworkLink => Network.GetCustomValue(); /// /// Gets or sets the value of the password (ab) /// [NotMapped] public string Password { get => Cryptor.TryDecrypt(EncryptedPassword, out var password) ? password : string.Empty; set => EncryptedPassword = Cryptor.Encrypt(value); } /// /// Gets or sets the value of the type (ab) /// public UserType Type { get; set; } /// /// Gets or sets the value of the verified (ab) /// public bool Verified { get; set; } #endregion #region Public Method Clone /// /// Clones this instance (a. beging, 11.04.2022) /// /// The user public User Clone() => (User)MemberwiseClone(); #endregion } }