Files
FoodsharingOnboarding/FoodsharingSiegen.Contracts/Entity/User.cs
2022-04-08 16:10:26 +02:00

43 lines
1.2 KiB
C#

using System.ComponentModel.DataAnnotations.Schema;
using FoodsharingSiegen.Shared.Helper;
namespace FoodsharingSiegen.Contracts.Entity
{
/// <summary>
/// The user class (a. beging, 06.04.2022)
/// </summary>
public partial class User
{
#region Public Properties
/// <summary>
/// Gets or sets the value of the groups list (ab)
/// </summary>
[NotMapped]
public List<UserGroup> GroupsList
{
get
{
if (string.IsNullOrWhiteSpace(Groups)) return new List<UserGroup>();
var stringList = Groups.Split(",");
var enumList = stringList.Where(x => !string.IsNullOrWhiteSpace(x)).Select(Enum.Parse<UserGroup>).ToList();
return enumList;
}
set => Groups = string.Join(",", value);
}
/// <summary>
/// Gets or sets the value of the password (ab)
/// </summary>
[NotMapped]
public string Password
{
get => AuthHelper.TryDecrypt(EncryptedPassword, out var password) ? password : string.Empty;
set => EncryptedPassword = AuthHelper.Encrypt(value);
}
#endregion
}
}