public void Authenticate(string adUser)
 {
     try
     {
         adUser = _config.DomainUser + adUser;
         var response = _role.GetCompositeRoleItemByAdUser(adUser);
         Console.WriteLine(response);
     }
     catch (Exception ex)
     {
         Assert.True(false, ex.Message);
     }
 }
        /// <summary>
        /// The Method Add ClaimsIdentity Properties.
        /// </summary>
        /// <param name="username">The identity user.</param>
        public EmployeeViewModel ManageClaimsIdentity(LoginViewModel login)
        {
            Hremployee data = _unitOfWork.GetRepository <Hremployee>().Get(x => x.Aduser == login.Username).FirstOrDefault();

            if (data == null)
            {
                throw new ArgumentNullException(ConstantValue.HrEmployeeArgumentNullExceptionMessage);
            }
            var result = new EmployeeViewModel
            {
                EmpNo       = data.EmpNo,
                FirstNameTH = data.FirstnameTh,
                LastNameTH  = data.LastnameTh,
                AdUser      = data.Aduser,
                ComCode     = data.ComCode,
                OrgId       = data.OrgId,
                PositionId  = data.PositionId
            };
            var sapComCode = _unitOfWork.GetRepository <Hrcompany>().GetCache(x => x.ComCode == data.ComCode).FirstOrDefault()?.SapcomCode;
            var roleList   = _roleBll.GetCompositeRoleItemByAdUser(login.Username);

            _identity = new ClaimsIdentity();
            _identity.AddClaim(new Claim(ClaimTypes.Name, data.Aduser));
            _identity.AddClaim(new Claim(ConstantValue.ClamisEncrypt, UtilityService.EncryptString(login.Password, _config.EncryptionKey)));
            _identity.AddClaim(new Claim(ConstantValue.ClamisEmpNo, data.EmpNo));
            _identity.AddClaim(new Claim(ConstantValue.ClamisName, string.Format(ConstantValue.EmpTemplate, data.FirstnameTh, data.LastnameTh)));
            _identity.AddClaim(new Claim(ConstantValue.ClamisOrg, data.OrgId));
            _identity.AddClaim(new Claim(ConstantValue.ClamisPosition, data.PositionId));
            _identity.AddClaim(new Claim(ConstantValue.ClamisComCode, sapComCode));
            //Add authority company
            var authorityList = _unitOfWork.GetRepository <AuthorityCompany>().GetCache(x => x.AdUser == data.Aduser);

            foreach (var item in authorityList)
            {
                _identity.AddClaim(new Claim(ConstantValue.ClamisComCode, item.ComCode));
            }
            //Add purchase org
            var purOrgs = _unitOfWork.GetRepository <PurchaseOrgItem>().GetCache(x => x.AdUser == data.Aduser);

            foreach (var item in purOrgs)
            {
                _identity.AddClaim(new Claim(ConstantValue.ClamisPurchasing, item.PuchaseOrg));
            }
            //Add role
            foreach (var item in roleList)
            {
                _identity.AddClaim(new Claim(ClaimTypes.Role, item.RoleMenu));
            }
            return(result);
        }
 /// <summary>
 /// Generate Menu.
 /// </summary>
 /// <param name="adUser">The ad user.</param>
 /// <returns></returns>
 public IEnumerable <MenuViewModel> GenerateMenu(string adUser)
 {
     return(this.GetMenu(_roleBll.GetCompositeRoleItemByAdUser(adUser)));
 }