Пример #1
0
        public ActionResult EditBuild(BuildSearchModel model)
        {
            JsonModel jm = new JsonModel();

            //如果表单模型验证成功
            if (ModelState.IsValid)
            {
                IBuildBLL buildBll = BLLFactory <IBuildBLL> .GetBLL("BuildBLL");

                T_Build buildInfo = buildBll.GetEntity(m => m.Id == model.Id);
                if (buildInfo != null)
                {
                    buildInfo.BuildName = model.BuildName;
                    buildInfo.Desc      = model.Desc;
                    // 保存到数据库
                    buildBll.Update(buildInfo);

                    //日志记录
                    jm.Content = PropertyUtils.ModelToJsonString(model);
                }
                else
                {
                    jm.Msg = "该楼座不存在";
                }
            }
            else
            {
                // 保存异常日志
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public ActionResult AddBuild(BuildSearchModel model)
        {
            JsonModel jm = new JsonModel();

            //如果表单模型验证成功
            if (ModelState.IsValid)
            {
                IBuildBLL buildBll = BLLFactory <IBuildBLL> .GetBLL("BuildBLL");

                T_Build newBuild = new T_Build()
                {
                    BuildName       = model.BuildName,
                    PropertyPlaceId = model.PropertyPlaceId,
                    Desc            = model.Desc
                };
                // 保存到数据库
                buildBll.Save(newBuild);

                //日志记录
                jm.Content = PropertyUtils.ModelToJsonString(model);
            }
            else
            {
                // 保存异常日志
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
Пример #3
0
        /// <summary>
        /// 获取楼座Id, 如果没有将新建一个楼座
        /// </summary>
        /// <param name="buildName"></param>
        /// <param name="propertPlaceId"></param>
        /// <returns></returns>
        private static int GetBuildId(string buildName, int propertPlaceId)
        {
            int buildId = 0;
            //楼座接口
            IBuildBLL buildBll = BLLFactory <IBuildBLL> .GetBLL("BuildBLL");

            var build = buildBll.GetEntity(b => b.BuildName == buildName && b.PropertyPlaceId == propertPlaceId);

            if (build != null)
            {
                buildId = build.Id;
            }
            else
            {
                build = new T_Build()
                {
                    BuildName       = buildName,
                    PropertyPlaceId = propertPlaceId,
                };
                try
                {
                    buildBll.Save(build);
                    buildId = build.Id;
                }
                catch
                {
                    buildId = 0;
                }
            }

            return(buildId);
        }