using HRD.WebApi.DAL;
using System;
using System.ComponentModel.DataAnnotations.Schema;

namespace DAL._Shared.SharedModels
{
    public partial class WebAppUser : BaseEntity
    {
        public WebAppUser()
        {
        }

        public WebAppUser(string loginName, string shortName, string roleList, string name)
        {
            LoginName = loginName;
            ShortName = shortName;
            RoleList = roleList;
            Name = name;
        }

        public int WebAppUserId { get; set; }
        public string Name { get; set; }
        public string ShortName { get; set; }

        public string LoginName { get; set; }

        public string Password { get; set; } = string.Empty;
        public string RoleList { get; set; }
        public string WebAppRoleList { get; set; } = string.Empty;

        public DateTime? JwtExpiredOn { get; set; }
        public DateTime? LastLogin { get; set; }

        [NotMapped]
        public string Token { get; set; }

        public string ClientVersion { get; set; }

        [NotMapped]
        public int TimeZoneOffsetInMin { get; set; }

        public string Language { get; set; }
        public string Culture { get; set; }

        public bool IsGermanCulture() => Culture?.Substring(0, 2).ToLower() == "de";

        //generic Id
        public override int GetEntityId() => WebAppUserId;

        //generic ToString()
        public override string ToString() => $"WebAppUserId: {GetEntityId()}; Name: {Name}";

        //generic EntityInfo()
        public override string EntityInfo()
        {
            return $"WebAppUserId: {GetEntityId()}; Loginname:{LoginName}; JwtExpiredOn:{JwtExpiredOn}";
        }
    }
}