/// <summary> /// 上传示意图 /// </summary> /// <param name="position">广告位</param> /// <param name="stream">图片流</param> private void UploadPositionImage(AdvertisingPosition position, Stream stream) { if (stream != null) { LogoService logoService = new LogoService(TenantTypeIds.Instance().AdvertisingPosition()); position.FeaturedImage = logoService.UploadLogo(position.PositionId, stream); advertisingPositionRepository.Update(position); } }
/// <summary> /// 新建实体时使用 /// </summary> public static AdvertisingPosition New() { AdvertisingPosition advertisingPosition = new AdvertisingPosition() { Description = string.Empty, FeaturedImage = string.Empty }; return(advertisingPosition); }
/// <summary> /// 删除广告位示意图 /// </summary> /// <param name="positionId">广告位Id</param> public void DeletePositionImage(string positionId) { LogoService logoService = new LogoService(TenantTypeIds.Instance().AdvertisingPosition()); logoService.DeleteLogo(positionId); AdvertisingPosition position = GetPosition(positionId); if (position == null) { return; } position.FeaturedImage = string.Empty; advertisingPositionRepository.Update(position); }
/// <summary> /// 删除广告位 /// </summary> /// <param name="positionId"></param> /// <returns></returns> public bool DeletePosition(string positionId) { AdvertisingPosition position = advertisingPositionRepository.Get(positionId); int result = advertisingPositionRepository.Delete(position); if (result > 0) { LogoService logoService = new LogoService(TenantTypeIds.Instance().AdvertisingPosition()); logoService.DeleteLogo(positionId); return(true); } else { return(false); } }
/// <summary> /// 创建广告位 /// </summary> /// <param name="position">广告位</param> /// <param name="stream">图片流</param> /// <returns></returns> public bool CreatePosition(AdvertisingPosition position, Stream stream) { advertisingPositionRepository.Insert(position); AdvertisingPosition advertisingPosition = advertisingPositionRepository.Get(position.PositionId); if (advertisingPosition != null) { UploadPositionImage(position, stream); return(true); } else { return(false); } }
/// <summary> /// 新建实体时使用 /// </summary> public static AdvertisingPosition New() { AdvertisingPosition advertisingPosition = new AdvertisingPosition() { Description = string.Empty, FeaturedImage = string.Empty }; return advertisingPosition; }
/// <summary> /// 更新广告位 /// </summary> /// <param name="position">广告位</param> /// <param name="stream">图片流</param> public void UpdatePosition(AdvertisingPosition position, Stream stream) { advertisingPositionRepository.Update(position); UploadPositionImage(position, stream); }
/// <summary> /// 创建广告位 /// </summary> /// <param name="position">广告位</param> /// <param name="stream">图片流</param> /// <returns></returns> public bool CreatePosition(AdvertisingPosition position, Stream stream) { advertisingPositionRepository.Insert(position); AdvertisingPosition advertisingPosition = advertisingPositionRepository.Get(position.PositionId); if (advertisingPosition != null) { UploadPositionImage(position, stream); return true; } else { return false; } }