예제 #1
0
        public static void SaveLoginUser(TAdminUser adminUser)
        {
            if (!string.IsNullOrEmpty(adminUser.Token))
            {
                CacheHelper.RemoveAllCache(adminUser.Token);
            }

            var sessionUserModel = new AdminUserModel();

            UtilHelper.CopyProperties(adminUser, sessionUserModel, new string[] {
                "ID",
                "Account",
                "Avatar",
                "Token",
                "TokenExpired",
                "LastLoginDate",
                "LastLoginIP"
            });

            var role             = new RoleModel();
            var adminUserRoleBLL = new TAdminUserRoleBLL();
            var adminUserRole    = adminUserRoleBLL.Find(ur => ur.AdminUserID == sessionUserModel.ID);

            UtilHelper.CopyProperties(adminUserRole.TRole, role, new string[] {
                "ID",
                "Name"
            });

            sessionUserModel.RoleID = role.ID;
            sessionUserModel.Role   = role;

            CacheHelper.SetCache(adminUser.Token, sessionUserModel, new TimeSpan(0, 30, 0));
        }
예제 #2
0
        public APIJsonResult Edit(AdminUserEditModel adminUserModel)
        {
            var adminUserBLL = new TAdminUserBLL();
            var adminUser    = adminUserBLL.Find(u => u.ID == adminUserModel.ID);

            AddUpdateInfo(adminUser);

            List <string> updatedField = new List <string>();

            if (!string.IsNullOrEmpty(adminUserModel.Password))
            {
                adminUser.Password = EncryptHelper.EncryptString(adminUserModel.Password);
            }

            adminUser.Status = adminUserModel.Status;

            adminUserBLL.SaveChanges();

            var adminUserRoleBLL = new TAdminUserRoleBLL();
            var adminUserRole    = adminUserRoleBLL.Find(r => r.AdminUserID == adminUser.ID);

            adminUserRole.RoleID = adminUserModel.RoleID;

            AddUpdateInfo(adminUserRole);
            adminUserRoleBLL.SaveChanges();

            return(Success());
        }