Example #1
0
        public bool EditConfig(int oldParentId, SvrModels.SvrConfigInfo svrModel)
        {
            var checkModel = QWF.Framework.Validation.ValidationHelper.Validate(svrModel);

            if (!checkModel.IsValid)
            {
                throw new UIValidateException("数据验证失败!" + checkModel.ToString());
            }


            //
            using (var db = DbAccess.DbFrameworkContext.Create())
            {
                var helper = new BLL.ConfigHelper(db, this.svrUser);
                var config = helper.GetConfigNode(svrModel.ConfigId);

                if (config == null)
                {
                    throw new UIValidateException("配置节点不存在,ID=" + svrModel.ConfigId);
                }

                config.UpdateConfigNode(oldParentId, svrModel);
                db.SaveChanges();
                return(true);
            }
        }
Example #2
0
        /// <summary>
        /// 添加配置表节点
        /// </summary>
        /// <param name="parentId"></param>
        /// <param name="configName"></param>
        /// <returns></returns>
        public int AddConfig(int parentId, string configName)
        {
            using (var db = DbAccess.DbFrameworkContext.Create())
            {
                var helper = new BLL.ConfigHelper(db, svrUser);
                var config = helper.CreateConfigNode(parentId, configName);

                db.SaveChanges();
                return(config.ConfigId);
            }
        }
Example #3
0
        public bool DeleteConfig(int configId)
        {
            using (var db = DbAccess.DbFrameworkContext.Create())
            {
                var helper = new BLL.ConfigHelper(db, this.svrUser);
                var config = helper.GetConfigNode(configId);

                if (config == null)
                {
                    throw new UIValidateException("配置节点不存在,ID=" + configId);
                }

                config.Delete();
                db.SaveChanges();
                return(true);
            }
        }