private async Task saveImageToDisk(Articolo art) // async { HttpClient c = new HttpClient(); c.BaseAddress = new Uri(art.UrlImg); c.Timeout = new TimeSpan(0,0, 3); Byte[] imgByteArray = await c.GetByteArrayAsync (""); CancellationToken a = new CancellationToken(); IFolder rootFolder = FileSystem.Current.LocalStorage; IFolder folder = await rootFolder.CreateFolderAsync("Immagini", CreationCollisionOption.OpenIfExists); var listaFilePerVerifica = await folder.GetFilesAsync (new CancellationToken ()); var listafile = await folder.GetFilesAsync (); IFile file = await folder.CreateFileAsync(art.ImageFileName , CreationCollisionOption.ReplaceExisting); // http://www.mallibone.com/post/storing-files-from-the-portable-class-library-(pcl) using (var fileHandler = await file.OpenAsync (FileAccess.ReadAndWrite)) { fileHandler.WriteAsync(imgByteArray, 0, imgByteArray.Length); // await } }
public int SaveItem (Articolo item) { lock (locker) { if (item.Id != 0) { database.Update(item); return item.Id; } else { return database.Insert(item); } } }
public DetaglioPage(Articolo articolo) { _articolo = articolo; InitializeComponent (); Title = articolo.art_DESC; }