async void comment_button(object sender, EventArgs e) { var text = editor.Text; PictureComment c = new PictureComment(text, current_pic_id.ToString(), comment.Count.ToString(), DateTime.Now.ToString()); comment.Add(c); await ar.AddComment(c); lstView.ItemsSource = comment.Where((comment) => comment.PictureId.Contains(current_pic_id.ToString())); layout_editor.IsVisible = false; CarouselPics.IsVisible = true; editor.Text = ""; }
public async Task AddComment(PictureComment com) { CloudBlobClient blobClient = _storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference("xamarincommentcontainer"); await container.CreateIfNotExistsAsync(); CloudBlockBlob blockBlob = container.GetBlockBlobReference("comments_blob" + com.Id); blockBlob.Metadata.Add("Id", com.Id); blockBlob.Metadata.Add("PictureId", com.PictureId); blockBlob.Metadata.Add("PictureDate", com.CurrentDate); await blockBlob.UploadTextAsync(com.Comment); }
public async Task getCommentBlob(PhotosPage page) { CloudBlobClient blobClient = _storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference("xamarincommentcontainer"); await container.CreateIfNotExistsAsync(); BlobContinuationToken token = null; var s = await container.ListBlobsSegmentedAsync(token); PictureComment pc; foreach (IListBlobItem item in s.Results) { if (item.GetType() == typeof(CloudBlockBlob)) { var PictureId = ""; var Id = ""; var PictureDate = ""; CloudBlockBlob blob = (CloudBlockBlob)item; //byte[] blobBytes = new byte[blob.Properties.Length]; Debug.WriteLine("Block blob of length {0}: {1}", blob.Properties.Length, blob.Uri); var comment = await blob.DownloadTextAsync(); foreach (var metadataItem in blob.Metadata) { if (metadataItem.Key == "PictureId") { PictureId = metadataItem.Value.ToString(); } else if (metadataItem.Key == "Id") { Id = metadataItem.Value.ToString(); } else if (metadataItem.Key == "PictureDate") { PictureDate = metadataItem.Value.ToString(); } } Debug.WriteLine("Block blob of length {0}: {1}", PictureId, comment); pc = new PictureComment(comment, PictureId, Id, PictureDate); page.comment.Add(pc); } } }