示例#1
0
        public ActionResult UpdateSystemUserStatus(string customerSysNos, CommonStatus status)
        {
            var sysnolist = JsonConvert.DeserializeObject <List <int> >(customerSysNos);

            if (sysnolist.Count == 0)
            {
                throw new BusinessException("请勾选账号后再操作");
            }
            if (status == CommonStatus.Deleted)
            {
                throw new BusinessException("传入状态不正确!请刷新重试!");
            }
            var cuslist = user_service.QuerySystemUserListBySysNos(sysnolist, ConstValue.ApplicationID);

            if (CurrUser.MasterSysNo.GetValueOrDefault() > 0)
            {
                cuslist = cuslist.Where(e => e.MasterSysNo == CurrUser.MasterSysNo.Value).ToList();
            }
            AjaxResult result = new AjaxResult();

            if (status == CommonStatus.Actived)
            {
                cuslist = cuslist.Where(e => e.CommonStatus == CommonStatus.DeActived).ToList();
            }
            if (status == CommonStatus.DeActived)
            {
                cuslist = cuslist.Where(e => e.CommonStatus == CommonStatus.Actived).ToList();
            }
            if (cuslist.Count == 0)
            {
                if (status == CommonStatus.Actived)
                {
                    throw new BusinessException("选择的账号已是启用状态!请重新勾选后再试!");
                }
                if (status == CommonStatus.DeActived)
                {
                    throw new BusinessException("选择的账号已是禁用状态!请重新勾选后再试!");
                }
            }
            var sysnos = cuslist.Select(e => e.SysNo).ToList();

            user_service.UpdateSystemUserStatusBatch(sysnos, status, CurrUser);
            return(Json(new AjaxResult {
                Success = true, Data = sysnos.Count
            }));
        }