/// <summary> /// method to insert image from url to DB and set the relevant property of pokemon object /// </summary> /// <param name="pokemon">object which property needs to be set</param> public void setImageId(AnPokemonProxy pokemon) { var imageApi = new ImageAPI(userConnection); WebRequest imageRequest = WebRequest.Create(pokemon.ImageURL); MemoryStream Image = new MemoryStream(); imageRequest.GetResponse().GetResponseStream().CopyTo(Image); pokemon.ImageId = imageApi.Save(Image, "image/png", $"An{pokemon.Name}Image").ToString(); }
public virtual bool AfterContactSavedScriptTaskExecute(ProcessExecutingContext context) { if (PhotoHasChanged) { Guid photoId = Entity.GetTypedColumnValue <Guid>("PhotoId"); if (photoId != Guid.Empty) { ImageAPI imageApi = new ImageAPI(UserConnection); ImageData imageData = imageApi.Get(photoId); if (imageData.Stream.Length == 0) { imageApi.Save(imageData.PreviewStream, photoId); } else { imageApi.SaveThumbnail(photoId, 256, 256, null, 75); } } } return(true); }