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 DeleteDoor(int id)
        {
            JsonModel     jm      = new JsonModel();
            IBuildDoorBLL doorBll = BLLFactory <IBuildDoorBLL> .GetBLL("BuildDoorBLL");

            // 根据指定id值获取实体对象
            var door  = doorBll.GetEntity(index => index.Id == id);
            var count = door.HouseUsers.Where(p => p.DelFlag == 0).Count();

            if (door == null)
            {
                jm.Msg = "该单元户不存在";
            }
            else
            {
                if (doorBll.Delete(door))
                {
                    //操作日志
                    jm.Content = "删除单元户 " + door.DoorName;
                }
                else
                {
                    jm.Msg = "删除失败";
                }
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        public ActionResult EditDoor(int id)
        {
            IBuildDoorBLL doorBll = BLLFactory <IBuildDoorBLL> .GetBLL("BuildDoorBLL");

            var doorInfo = doorBll.GetEntity(index => index.Id == id);

            if (doorInfo != null)
            {
                BuildDoorSearchModel doorModel = new BuildDoorSearchModel();
                doorModel.BuildName = doorInfo.BuildUnit.Build.BuildName;
                doorModel.UnitName  = doorInfo.BuildUnit.UnitName;
                doorModel.UnitId    = doorInfo.BuildUnit.Id;
                doorModel.DoorId    = id;
                doorModel.DoorName  = doorInfo.DoorName;
                return(View(doorModel));
            }
            else
            {
                return(RedirectToAction("DoorList"));
            }
        }