public ActionResult Detail() { //获取登录物业公司 int CompanyId = GetSessionModel().CompanyId.Value; IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL"); T_Company company = propertyCompanyBll.GetEntity(m => m.Id == CompanyId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (company != null) { //初始化返回页面的模型 PropertyCompanyModel model = new PropertyCompanyModel() { Name = company.Name, Address = company.Address, Content = company.Content, Img = company.Img, Tel = company.Tel }; return(View(model)); } else { return(View()); } }
public ActionResult EditCompany() { int CompanyId = GetSessionModel().CompanyId.Value; IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL"); //获取要编辑的物业公司 T_Company company = propertyCompanyBll.GetEntity(m => m.Id == CompanyId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (company != null) { //初始化返回页面的模型 PropertyCompanyModel model = new PropertyCompanyModel() { Id = company.Id, Name = company.Name, Address = company.Address, Content = company.Content, Tel = company.Tel }; return(View(model)); } else { return(RedirectToAction("CompanyDetail")); } }
public ContentResult RemoteCheck(PropertyCompanyModel model) { IPropertyCompanyBLL propertyCompanybll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL"); if (propertyCompanybll.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 EditCompany(PropertyCompanyModel model) { JsonModel jm = new JsonModel(); //如果表单模型验证成功 if (ModelState.IsValid) { IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL"); T_Company company = propertyCompanyBll.GetEntity(m => m.Id == model.Id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (company != null) { company.Name = model.Name; company.Address = model.Address; company.Content = model.Content; company.Tel = model.Tel; //保存到数据库 if (propertyCompanyBll.Update(company)) { //日志记录 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)); }
public JsonResult AddCompany(PropertyCompanyModel model) { JsonModel jm = new JsonModel(); //如果表单模型验证成功 if (ModelState.IsValid) { IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL"); //如果图片不为空 if (model.UploadImg != null) { //存入文件的路径 string directory = Server.MapPath(ConstantParam.PROPERTY_COMPANY_DIR); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } HttpPostedFileBase file = model.UploadImg; string filename = Path.GetFileName(file.FileName); //获取上传文件名 string fileEx = System.IO.Path.GetExtension(filename); //获取上传文件扩展名 //存入的文件名 string FileName = DateTime.Now.ToFileTime().ToString() + fileEx; //保存的数据文件 string savrPath = Path.Combine(directory, FileName); file.SaveAs(savrPath); //初始化平台物业公司数据实体 T_Company company = new T_Company() { Name = model.Name, Address = model.Address, Content = model.Content, Tel = model.Tel, Img = ConstantParam.PROPERTY_COMPANY_DIR + FileName }; //保存 propertyCompanyBll.AddCompany(company); //日志记录 jm.Content = PropertyUtils.ModelToJsonString(company); } else { //初始化平台物业公司数据实体 T_Company Company = new T_Company() { Name = model.Name, Address = model.Address, Content = model.Content, Tel = model.Tel }; //保存 propertyCompanyBll.AddCompany(Company); //日志记录 jm.Content = PropertyUtils.ModelToJsonString(Company); } } else { jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }