using Newtonsoft.Json;
using JsonSerializer = System.Text.Json.JsonSerializer;

namespace Kafka.Lib.Auth.Model
{
    public class PrivilageModel
    {
        public string? Id { get; set; }
        public string? PrivilageName { get; set; }

        [JsonIgnore]
        public string Text
        {
            get => JsonSerializer.Serialize(this);
            set
            {
                if (!string.IsNullOrWhiteSpace(value))
                {
                    var obj = JsonSerializer.Deserialize<PrivilageModel>(value);

                    if (obj != null)
                    {
                        Id = obj.Id;
                        PrivilageName = obj.PrivilageName;
                    }
                }
            }
        }
    }
}