public bool DeleteImage(UploadImageViewModel uploadImageModel) { try { bool bl = UploadImageHelper.DeleteImage(uploadImageModel.mapPath); if (bl) { UpdateEMTenantLogoUrl(uploadImageModel.tenantCode, uploadImageModel.logoURL); return true; } else return false; } catch (Exception ex) { Logger.Info("DeleteImage(删除图片):"+ex.Message); return false; } }
public bool UploadImage(UploadImageViewModel uploadImageModel) { try { bool bl = UploadImageHelper.GetUpoladImg(uploadImageModel.mapPath, uploadImageModel.imgName, uploadImageModel.buffer); if (bl) { IEMTenantService service = new EMTenantService(); if (!string.IsNullOrEmpty(uploadImageModel.tenantCode)) { EMTenant emTenant = service.Select(uploadImageModel.tenantCode); string oldLogoUrlName = emTenant.LogoUrl; emTenant.LogoUrl = uploadImageModel.imgName; service.Update(emTenant); //判断是否默认图片 if (!string.IsNullOrEmpty(oldLogoUrlName)) { string oldMapPath = uploadImageModel.mapPath + "\\" + oldLogoUrlName; UploadImageHelper.DeleteImage(oldMapPath); } } return true; } else return false; } catch (Exception ex) { Logger.Info("UploadImage(上传图片):"+ex.Message); return false; } }