Esempio n. 1
0
 /// <summary>
 /// 查询用来修改的单点登录池实体
 /// </summary>
 /// <param name="poolId"></param>
 /// <returns></returns>
 public SSOPoolEditModel GetEditModel(int poolId)
 {
     ISSOPoolDal ssoPoolDal = new SSOPoolDal();
     SSOPoolEditModel editModel = new SSOPoolEditModel();
     var ssoPool = ssoPoolDal.GetEntity(poolId);
     if (ssoPool != null)
     {
         editModel = new SSOPoolEditModel()
        {
            PoolId = ssoPool.PoolId,
            PoolName = ssoPool.PoolName,
            IsEnabled = ssoPool.IsEnabled,
            MainDomainId = ssoPool.MainDomainId,
            MaxAmount = ssoPool.MaxAmount,
            ReMark = ssoPool.ReMark
        };
     }
     return editModel;
 }
 public ActionResult SSOPoolEdit(SSOPoolEditModel editModel)
 {
     ISSOPoolService service = new SSOPoolService();
     var jsonModel = service.EditSSOPool(editModel);
     if (jsonModel.Success)
     {
         return Json(new { success = true, msg = "修改成功" }, JsonRequestBehavior.AllowGet);
     }
     else
     {
         return Json(new { success = false, msg = jsonModel.ErrMsg }, JsonRequestBehavior.AllowGet);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// 修改单点登录池
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonModel<string> EditSSOPool(SSOPoolEditModel model)
        {
            JsonModel<string> jsonModel = new JsonModel<string>()
            {
                Success = false,
                SuccessMsg = "修改成功",
                ErrMsg = "修改失败"
            };

            //对实体进行验证
            var validate = DotNet.Utils.DataValidate.ValidateHelper<SSOPoolEditModel>.ValidateModel(model);
            if (!validate.Pass)
            {
                jsonModel.ErrMsg = validate.ResultList.FirstOrDefault().ErrorMessage;
                return jsonModel;
            }
            //字符过滤
            model.ReMark = DotNet.Utils.Untility.StringHelper.FilterHtml(model.ReMark);
            IDomainDal domainDal = new DomainDal();
            //检测选择的主要验证域是否正确
            if (model.MainDomainId > 0)
            {
                var domain = domainDal.GetEntity(model.MainDomainId);
                if (domain == null || domain.SSOPoolPoolId != model.PoolId)
                {
                    jsonModel.ErrMsg = "您选择的主要验证域不正确";
                    return jsonModel;
                }
            }
            //查看最大的域数量是否超出限制
            var poolDomainCount = domainDal.GetPoolDomain(model.PoolId).Count;
            if (poolDomainCount > model.MaxAmount)
            {
                jsonModel.ErrMsg = string.Format("您输入的最大域数量不正确,应大于{0}", poolDomainCount);
                return jsonModel;
            }

            ISSOPoolDal ssoPoolDal = new SSOPoolDal();
            var dbPool = ssoPoolDal.GetEntity(model.PoolId);
            if (dbPool != null)
            {
                dbPool.PoolName = model.PoolName;
                dbPool.MainDomainId = model.MainDomainId;
                dbPool.IsEnabled = model.IsEnabled;
                dbPool.MaxAmount = model.MaxAmount;
                dbPool.ReMark = model.ReMark;
            }
            var r = ssoPoolDal.UpdateEntity(dbPool);
            if (r != null && r.PoolId > 0)
            {
                jsonModel.Success = true;
            }

            return jsonModel;
        }