using System;
using System.Text;

namespace Bp.Sync.Dto.Models
{
    public class BaseAppModel
    {
        public string Token { get; set; }
        public int UserId
        {
            get
            {
                if (!string.IsNullOrEmpty(Token))
                {
                    string key = Encoding.UTF8.GetString(Convert.FromBase64String(Token));
                    string[] parts = key.Split(new char[] { ':' });
                    if (parts.Length == 3)
                    {
                        return int.Parse(parts[2]);
                    }
                }
                return 0;
            }
        }
    }
}
