Esempio n. 1
0
 /// <summary>
 /// 添加池的数据
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public SSOPool AddEntity(SSOPool entity)
 {
     try
     {
         using (var connection = ConnectionFactory.GetMasterSql())
         {
             string sql = @"Insert into B_SSOPool values(@PoolName,@IsEnabled,@MaxAmount,@MainDomainId,@DelFlag,@ReMark);select @@identity;";
             var id = connection.ExecuteScalar<int>(sql, new { PoolName = entity.PoolName, IsEnabled = entity.IsEnabled, MaxAmount = entity.MaxAmount, MainDomainId = entity.MainDomainId, DelFlag = (int)DelFlagEnum.Noraml, ReMark = entity.ReMark });
             var pool = connection.Query<SSOPool>(@"Select * from B_SSOPool where PoolId=@PoolId", new { PoolId = id }).FirstOrDefault();
             return pool;
         }
     }
     catch
     {
         return null;
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 添加一个单点登录池
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public JsonModel<string> AddSSOPool(SSOPoolAddModel model)
 {
     JsonModel<string> jsonModel = new JsonModel<string>()
     {
         Success = false,
         SuccessMsg = "添加成功",
         ErrMsg = "添加失败"
     };
     //对实体进行验证
     var validate = DotNet.Utils.DataValidate.ValidateHelper<SSOPoolAddModel>.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)
         {
             jsonModel.ErrMsg = "主域不存在";
             return jsonModel;
         }
     }
     //构建实体
     SSOPool pool = new SSOPool()
     {
         PoolName = model.PoolName,
         IsEnabled = model.IsEnabled,
         MaxAmount = model.MaxAmount,
         MainDomainId = model.MainDomainId,
         DelFlag = (int)DelFlagEnum.Noraml,
         ReMark = model.ReMark
     };
     ISSOPoolDal ssoPoolDal = new SSOPoolDal();
     var r = ssoPoolDal.AddEntity(pool);
     if (r != null)
     {
         jsonModel.Success = true;
     }
     return jsonModel;
 }
Esempio n. 3
0
        /// <summary>
        ///  修改池子数据
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public SSOPool UpdateEntity(SSOPool entity)
        {
            try
            {
                using (var connection = ConnectionFactory.GetMasterSql())
                {
                    var dbPool = connection.Query<Domain>(@"Select * from B_SSOPool where PoolId=@PoolId", new { PoolId = @entity.PoolId }).FirstOrDefault();
                    if (dbPool == null)
                    {
                        return null;
                    }

                    string sql = @"Update B_SSOPool set PoolName=@PoolName,IsEnabled=@IsEnabled,MaxAmount=@MaxAmount,MainDomainId=@MainDomainId,DelFlag=@DelFlag,ReMark=@ReMark where PoolId=@PoolId ";
                    var r = connection.Execute(sql, new { PoolName = entity.PoolName, IsEnabled = entity.IsEnabled, MaxAmount = entity.MaxAmount, MainDomainId = entity.MainDomainId, DelFlag = entity.DelFlag, ReMark = entity.ReMark, PoolId = entity.PoolId });
                    if (r > 0)
                    {
                        var model = connection.Query<SSOPool>(@"Select * from B_SSOPool where PoolId=@PoolId", new { PoolId = @entity.PoolId }).FirstOrDefault();
                        return model;
                    }
                    else
                    {
                        return null;
                    }

                }
            }
            catch
            {
                return null;
            }
        }