Esempio n. 1
0
 public static IQueryable <T> RoleFilter <T>(IQueryable <T> data)
 {
     if (!GlobalVariant.GetAppUser().SysRole.IsAdmin&& GlobalVariant.GetSysOption()["RoleFilter"].ToString().Split(',').Contains(GlobalVariant.GetAppUser().SysRole.Name))
     {
         string strfilter = string.Format(" CreatedBy=={0} ", GlobalVariant.GetAppUser().UserID);
         return(data.Where(strfilter).AsQueryable());
     }
     return(data);
 }
Esempio n. 2
0
        public static SysUserView GetAppUserById(int?UserID)
        {
            var db = new WebApp.Areas.Accounting.Models.WebAppAccEntities(GlobalVariant.GetConnection());

            if (db != null)
            {
                int _UserID = UserID ?? 0;
                return(db.SysUserViews.SingleOrDefault(m => m.UserID == _UserID));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 3
0
        //string usercachekey = "AppAccountingUserKey";
        public static bool Login(string username, string password)
        {
            string strPassword = Accounting.Services.MD5.GenerateHashDigest(username + password);


            Accounting.Models.WebAppAccEntities db = new Models.WebAppAccEntities(Services.GlobalVariant.GetConnection());

            var user = db.SysUserViews.Where(m => m.Name == username && m.Password == strPassword).FirstOrDefault();

            if (user != null)
            {
                //lưu user vào cache
                GlobalVariant.SetAppUser(user);
                return(true);
            }

            return(false);
        }