public ActionResult BuildCompanyList(BuildCompanyModel model)
        {
            //物业公司Id
            int CompanyId = GetSessionModel().CompanyId.Value;

            IBuildCompanyBLL buildCompanyBll = BLLFactory <IBuildCompanyBLL> .GetBLL("BuildCompanyBLL");

            //查询
            Expression <Func <T_BuildCompany, bool> > where = u => (string.IsNullOrEmpty(model.Name) ? true : u.Name.Contains(model.Name)) && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT && u.PropertyPlace.CompanyId == CompanyId && u.PropertyPlace.PlaceType == ConstantParam.PLACE_TYPE_COMPANY;

            //根据小区名称查询
            if (model.PropertyPlaceId != null)
            {
                where = PredicateBuilder.And(where, u => u.PropertyPlaceId == model.PropertyPlaceId.Value);
            }

            //排序
            var sortModel = this.SettingSorting("Id", false);

            model.DataList = buildCompanyBll.GetPageList(where, sortModel.SortName, sortModel.IsAsc, model.PageIndex) as PagedList <T_BuildCompany>;

            //获取所有物业小区列表
            model.CompanyPlaceList = GetCompanyPlaceList();

            return(View(model));
        }
        public ActionResult AddBuildCompany(BuildCompanyModel model)
        {
            JsonModel jm = new JsonModel();

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

                T_BuildCompany buildCompany = new T_BuildCompany()
                {
                    Name            = model.Name,
                    Phone           = model.Phone,
                    Desc            = model.Desc,
                    PayDesc         = model.PayDesc,
                    ServiceDesc     = model.ServiceDesc,
                    PropertyPlaceId = GetSessionModel().PropertyPlaceId.Value
                };
                // 保存
                buildCompanyBll.Save(buildCompany);

                //日志记录
                jm.Content = PropertyUtils.ModelToJsonString(model);
            }
            else
            {
                // 保存异常日志
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
        public ActionResult EditBuildCompany(int id)
        {
            IBuildCompanyBLL buildCompanyBll = BLLFactory <IBuildCompanyBLL> .GetBLL("BuildCompanyBLL");

            //获取要编辑的物业公司
            T_BuildCompany buildCompany = buildCompanyBll.GetEntity(m => m.Id == id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            if (buildCompany != null)
            {
                //初始化返回页面的模型
                BuildCompanyModel model = new BuildCompanyModel()
                {
                    Id          = buildCompany.Id,
                    Name        = buildCompany.Name,
                    Phone       = buildCompany.Phone,
                    Desc        = buildCompany.Desc,
                    PayDesc     = buildCompany.PayDesc,
                    ServiceDesc = buildCompany.ServiceDesc
                };
                return(View(model));
            }
            else
            {
                return(RedirectToAction("BuildCompanyList"));
            }
        }
        public ActionResult BuildCompanyList(BuildCompanyModel model)
        {
            IBuildCompanyBLL buildCompanyBll = BLLFactory <IBuildCompanyBLL> .GetBLL("BuildCompanyBLL");

            int propertyPlaceId = GetSessionModel().PropertyPlaceId.Value;

            //查询
            Expression <Func <T_BuildCompany, bool> > where = u => (string.IsNullOrEmpty(model.Name) ? true : u.Name.Contains(model.Name)) && u.DelFlag == Property.Common.ConstantParam.DEL_FLAG_DEFAULT && u.PropertyPlaceId == propertyPlaceId;
            //排序
            var sortModel = this.SettingSorting("Id", false);
            var list      = buildCompanyBll.GetPageList(where, sortModel.SortName, sortModel.IsAsc, model.PageIndex);

            return(View(list));
        }
        public ContentResult RemoteCheckExist(BuildCompanyModel model)
        {
            IBuildCompanyBLL buildCompanyBll = BLLFactory <IBuildCompanyBLL> .GetBLL("BuildCompanyBLL");

            // 用户名已存在
            if (buildCompanyBll.Exist(m => m.Name == model.Name && m.Id != model.Id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT))
            {
                // 校验不通过

                return(Content("false"));
            }
            else
            {
                return(Content("true"));
            }
        }
        public JsonResult EditBuildCompany(BuildCompanyModel model)
        {
            JsonModel jm = new JsonModel();

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

                T_BuildCompany buildCompany = buildCompanyBll.GetEntity(m => m.Id == model.Id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                if (buildCompany != null)
                {
                    buildCompany.Name        = model.Name;
                    buildCompany.Phone       = model.Phone;
                    buildCompany.Desc        = model.Desc;
                    buildCompany.PayDesc     = model.PayDesc;
                    buildCompany.ServiceDesc = model.ServiceDesc;
                    //保存到数据库
                    if (buildCompanyBll.Update(buildCompany))
                    {
                        //日志记录
                        jm.Content = PropertyUtils.ModelToJsonString(model);
                    }
                    else
                    {
                        jm.Msg = "编辑失败";
                    }
                }
                else
                {
                    jm.Msg = "该办公楼单位业主不存在";
                }
            }
            else
            {
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }