Exemplo n.º 1
0
        /// <summary>
        /// 获取单元户Id, 如果没有将新建一个单元户
        /// </summary>
        /// <param name="doorName"></param>
        /// <param name="unitId"></param>
        /// <returns></returns>
        private static int GetBuildDoorId(string doorName, int unitId)
        {
            int doorId = 0;
            //楼座接口
            IBuildDoorBLL doorBll = BLLFactory <IBuildDoorBLL> .GetBLL("BuildDoorBLL");

            var door = doorBll.GetEntity(b => b.DoorName == doorName && b.UnitId == unitId);

            if (door != null)
            {
                doorId = door.Id;
            }
            else
            {
                door = new T_BuildDoor()
                {
                    DoorName = doorName,
                    UnitId   = unitId
                };

                try
                {
                    doorBll.Save(door);
                    doorId = door.Id;
                }
                catch (Exception)
                {
                    doorId = 0;
                }
            }

            return(doorId);
        }
Exemplo n.º 2
0
        public ActionResult EditDoor(BuildDoorSearchModel model)
        {
            JsonModel jm = new JsonModel();

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

                T_BuildDoor doorInfo = doorBll.GetEntity(m => m.Id == model.DoorId);
                if (doorInfo != null)
                {
                    doorInfo.DoorName = model.DoorName;
                    // 保存到数据库
                    doorBll.Update(doorInfo);

                    //日志记录
                    jm.Content = PropertyUtils.ModelToJsonString(model);
                }
                else
                {
                    jm.Msg = "该单元户不存在";
                }
            }
            else
            {
                // 保存异常日志
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public ActionResult AddDoor(BuildDoorSearchModel model)
        {
            JsonModel     jm      = new JsonModel();
            IBuildDoorBLL doorBll = BLLFactory <IBuildDoorBLL> .GetBLL("BuildDoorBLL");

            if (doorBll.Exist(m => m.DoorName == model.DoorName && m.Id != model.DoorId && m.UnitId == model.UnitId))
            {
                jm.Msg = "该单元户名称已经存在";
            }
            //如果表单模型验证成功
            else if (ModelState.IsValid)
            {
                T_BuildDoor newDoor = new T_BuildDoor()
                {
                    DoorName = model.DoorName,
                    UnitId   = model.UnitId
                };
                // 保存到数据库
                doorBll.Save(newDoor);

                //日志记录
                jm.Content = PropertyUtils.ModelToJsonString(model);
            }
            else
            {
                // 保存异常日志
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        public ActionResult BatchAddDoor(BuildDoorBatchAddModel model, int BuildId)
        {
            JsonModel jm     = new JsonModel();
            var       unitId = model.UnitId;
            var       result = RemoteCheck(model, BuildId);

            if (!string.IsNullOrEmpty(result))
            {
                // 保存异常日志
                jm.Msg = result + "单元户名已存在";
                return(Json(jm, JsonRequestBehavior.AllowGet));
            }

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

                List <T_BuildDoor> list = new List <T_BuildDoor>();
                for (int i = 0; i < model.DoorName.Length; i++)
                {
                    T_BuildDoor newDoor = new T_BuildDoor()
                    {
                        DoorName = model.DoorName[i],
                        UnitId   = model.UnitId
                    };
                    list.Add(newDoor);
                }
                // 批量保存
                doorBll.BatchAddDoor(model.UnitId, list);
                //日志记录
                jm.Content = PropertyUtils.ModelToJsonString(model);
            }
            else
            {
                // 保存异常日志
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }