コード例 #1
0
ファイル: AdminUserBLL.cs プロジェクト: QJesus/ASP.Net-MVC
        /// <summary>
        /// 批量禁用管理员, 返回受影响的行数
        /// </summary>
        public void BatchDisable(List<long> ids)
        {
            int dbNums = new AdminUserBLL(new HengNuoWangDBContext()).GetAdminUserNames(ids).Count;
            if (ids.Count != dbNums)
            {
                string error = string.Format("禁用管理员是发生错误:'{0}'包含未知管理员", string.Join(",", ids));
                throw new Exception(error);
            }

            dal.BatchDisable(ids);
        }
コード例 #2
0
        public ActionResult BatchDisable(string ids)
        {
            // 校验数据
            List<long> adminUserIds;
            bool requestOk = AdminHelper.GetRequestIds(ids, out adminUserIds);
            if (!requestOk)
            {
                return JsonHelper.GetJsonResult(_ERROR, "没有要禁用的账户 或 参数错误");
            }
            if (adminUserIds.Contains(AdminUserId))
            {
                return JsonHelper.GetJsonResult(_ERROR, "不能禁用自己");
            }

            List<string> names = new AdminUserBLL(new HengNuoWangDBContext()).GetAdminUserNames(adminUserIds);
            // 禁用
            _adminUserBll.BatchDisable(adminUserIds);

            // 记录操作日志, 跳转到列表页面
            _adminOperationLogBll.AddAdminOperationLog(AdminUserId,
                string.Format("批量禁用管理员: {0}", string.Join(",", names)));
            return JsonHelper.GetJsonResult(_OK, "批量禁用成功", "/AdminUser/List");
        }
コード例 #3
0
 public CameraController()
 {
     _adminUserBll = new AdminUserBLL(WebHelper.DbContext);
     _upyun = new UpYun(_bucket, _username, _password);
     _random = new Random();
 }
コード例 #4
0
        public ActionResult Edit(long id, string roleids)
        {
            List<long> roleIds;
            AdminUser adminUser;
            if (!AdminHelper.GetRequestIds(roleids, out roleIds, false) ||
                (adminUser = new AdminUserBLL(new HengNuoWangDBContext()).GetAdminUser(id)) == null)
            {
                return JsonHelper.GetJsonResult(_ERROR, "参数错误");
            }
            if (CommonHelper.IsListEquals(_adminUserRoleBll.GetRoleIdsOfAdminUser(adminUser.Id),
                                          roleIds))                                 // 判断两个List是否相同
            {
                return JsonHelper.GetJsonResult(_ERROR, "所属角色没有变化");
            }
            List<string> oldNames = _adminUserRoleBll.GetRoleNamesOfAdminUser(adminUser.Id);
            _adminUserBll.ChangeRole(adminUser.Id, roleIds);                                     // 更改
            List<string> newNames = _adminUserRoleBll.GetRoleNamesOfAdminUser(adminUser.Id);

            // 记录日志
            _adminOperationLogBll.AddAdminOperationLog(AdminUserId,
                string.Format("修改账号【{0}】角色'{1}'=>'{2}'",
                adminUser.UserName, string.Join(",", oldNames),
                string.Join(",", newNames)));                       // 记录日志
            return JsonHelper.GetJsonResult(_OK, "角色改变成功", "/AdminUser/List");
        }