public ActionResult EditCompany(int id) { IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL"); //获取要编辑的物业公司 T_Company company = propertyCompanyBll.GetEntity(m => m.Id == id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (company != null) { //初始化返回页面的模型 SetPropertyCompanyModel model = new SetPropertyCompanyModel() { Id = company.Id, Name = company.Name, Address = company.Address, Content = company.Content, Tel = company.Tel, Img = company.Img }; return(View(model)); } else { return(RedirectToAction("CompanyList")); } }
public JsonResult SetCompanyInfo(SetPropertyCompanyModel model) { JsonModel jm = new JsonModel(); if (ModelState.IsValid) { //存入文件的路径 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 = Path.GetExtension(filename); //获取上传文件的扩展名 //存入的文件名 string FileName = DateTime.Now.ToFileTime().ToString() + fileEx; //保存数据文件 string savrPath = Path.Combine(directory, FileName); file.SaveAs(savrPath); 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) { string oldFile = company.Img; company.Img = ConstantParam.PROPERTY_COMPANY_DIR + FileName; propertyCompanyBll.Update(company); //删除旧图标 if (!string.IsNullOrEmpty(oldFile)) { oldFile = Server.MapPath(oldFile); FileInfo f = new FileInfo(oldFile); if (f.Exists) { f.Delete(); } } } //日志记录 //jm.Content = PropertyUtils.ModelToJsonString(company); } else { jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public ActionResult SetPlatCompanyInfo(int id) { IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL"); T_Company company = propertyCompanyBll.GetEntity(m => m.Id == id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (company != null) { SetPropertyCompanyModel model = new SetPropertyCompanyModel() { Id = id, Img = company.Img }; return(View(model)); } else { return(RedirectToAction("CompanyList")); } }