Exemplo n.º 1
0
        public async Task <TH_HOSOKHACHHANG> GetHoSoKhachHang(int?ID)
        {
            try
            {
                using (APAXEntities3 db = new APAXEntities3())
                {
                    if (ID > 0)
                    {
                        TH_HOSOKHACHHANG model = await Task.Run(() => db.TH_HOSOKHACHHANG.FirstOrDefault(it => it.A_HOSOKHACHHANG == ID));

                        return(model);
                    }
                    return(null);
                }
            }
            catch { return(null); }
        }
Exemplo n.º 2
0
 public string[] GetAllRolesByUser(string userName)
 {
     try
     {
         using (APAXEntities3 db = new APAXEntities3())
         {
             TH_HOSOKHACHHANG Quyen = db.TH_HOSOKHACHHANG.FirstOrDefault(it => it.TAIKHOAN.Equals(userName));
             if (Quyen != null && Quyen.ID_QUYENNGUOIDUNG > 0)
             {
                 var strQuyen = db.DM_QUYEN.FirstOrDefault(it => it.A_QUYEN == Quyen.ID_QUYENNGUOIDUNG);
                 return(strQuyen != null?strQuyen.QUYENNGUOIDUNG.Split(',') : null);
             }
             return(null);
         }
     }
     catch { return(null); }
 }
Exemplo n.º 3
0
 public override string[] GetRolesForUser(string userName)
 {
     try
     {
         if (userName.Equals("Administrator"))
         {
             List <string> Quyen = new List <string>();
             Quyen.Add("0=0");
             return(Quyen.ToArray());
         }
         using (APAXEntities3 db = new APAXEntities3())
         {
             TH_HOSOKHACHHANG nguoiDung = db.TH_HOSOKHACHHANG.FirstOrDefault(it => it.TAIKHOAN.Equals(userName));
             if (nguoiDung != null)
             {
                 string[]      _Quyen    = null;
                 List <string> Quyen     = new List <string>();
                 string[]      QuyenUser = GetAllRolesByUser(userName);
                 if (QuyenUser != null)
                 {
                     Quyen.AddRange(QuyenUser);
                 }
                 if (Quyen.Count > 0)
                 {
                     _Quyen = Quyen.Distinct().ToArray();
                 }
                 if (_Quyen == null)
                 {
                     _Quyen[0] = "IsNull";
                 }
                 return(_Quyen);
             }
         }
         List <string> Quyen0 = new List <string>();
         Quyen0.Add("IsNull");
         return(Quyen0.ToArray());
     }
     catch
     {
         List <string> Quyen = new List <string>();
         Quyen.Add("IsNull");
         return(Quyen.ToArray());
     }
 }
Exemplo n.º 4
0
        public async Task <int> GetUserID(HttpCookieCollection Cookies)
        {
            try
            {
                using (APAXEntities3 db = new APAXEntities3())
                {
                    string           userName = GetUserName().ToLower();
                    TH_HOSOKHACHHANG model    = await Task.Run(() => db.TH_HOSOKHACHHANG
                                                               .FirstOrDefault(it => it.TAIKHOAN.ToLower().Equals(userName)));

                    if (model != null)
                    {
                        return(model.A_HOSOKHACHHANG);
                    }
                    else
                    {
                        return(1);
                    }
                }
            }
            catch { return(1); }
        }