﻿#region Copyright and License
/* @Copyright JONVON(NetCreditHub.COM) 2017. All rights reserved. - 8502090@qq.com */
#endregion

namespace NetCreditHub.Authorizations.Users
{
    using System;
    using System.ComponentModel.DataAnnotations;
    using System.ComponentModel.DataAnnotations.Schema;
    using Data.Entities.Auditing;
    using Extensions;

    [Table("hub_Users", Schema = "dbo")]
    public class User : FullAuditedWithUserNameEntity
    {
        #region The maximum length of string type field values

        public const int MaxUserNameLength = 64;

        public const int MaxUserCodeLength = 64;

        public const int MaxPasswordLength = 128;

        public const int MaxPasswordSaltLength = 64;

        public const int MaxMobileLength = 32;

        public const int MaxMobileConfirmationCodeLength = 64;

        public const int MaxEmailLength = 256;

        public const int MaxEmailConfirmationCodeLength = 64;

        public const int MaxPasswordResetCodeLength = 64;

        public const int MaxPasswordQuestionLength = 256;

        public const int MaxPasswordAnswerLength = 128;

        #endregion

        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public override long Id { get; set; }

        public virtual string UserName { get; set; }

        public virtual string UserCode { get; set; }

        public virtual string Password { get; set; }

        public virtual string PasswordSalt { get; set; }

        public virtual long OrganizationId { get; set; }

        public virtual long DepartmentId { get; set; }

        public virtual long RoleId { get; set; }

        public virtual long PostId { get; set; }

        public virtual long JobId { get; set; }

        public virtual long WorkGroupId { get; set; }

        public virtual string Mobile { get; set; }

        public virtual int MobileConfirmed { get; set; }

        public virtual string MobileConfirmationCode { get; set; }

        public virtual DateTime MobileConfirmationCodeSendingTime { get; set; }

        public virtual string Email { get; set; }

        public virtual int EmailConfirmed { get; set; }

        public virtual string EmailConfirmationCode { get; set; }

        public virtual DateTime EmailConfirmationCodeSendingTime { get; set; }

        public virtual string PasswordResetCode { get; set; }

        public virtual DateTime PasswordResetCodeSendingTime { get; set; }

        public virtual string PasswordQuestion { get; set; }

        public virtual string PasswordAnswer { get; set; }

        public virtual int AllowMultipleClientOnline { get; set; }

        public virtual int LoginCount { get; set; }

        public virtual int IsOnLine { get; set; }

        public virtual int AllowUpdatePassword { get; set; }

        public virtual int IsApproved { get; set; }

        public virtual int IsLock { get; set; }

        public virtual DateTime LastLoginTime { get; set; }

        public virtual DateTime LastPasswordChangedTime { get; set; }

        public virtual DateTime LastActivityTime { get; set; }

        public override string ToString()
        {
            return "[User > Id={0}, UserName={1}]".FormatWith(Id, UserName);
        }
    }
}