コード例 #1
0
ファイル: MainPage.cs プロジェクト: groovyc/newproject
 private async void ButtonSave_Click(object sender, RoutedEventArgs e)
 {
     var todoItem = new TodoItem { Text = TextInput.Text };
     await InsertTodoItem(todoItem);
 }
コード例 #2
0
ファイル: MainPage.cs プロジェクト: groovyc/newproject
        //private async Task InsertTodoItem(TodoItem todoItem)
        //{
        //    string errorString = string.Empty;

        //    if (media != null)
        //    {
        //        // Set blob properties of TodoItem.
        //        todoItem.ContainerName = "todoitemimages";

        //        // Use a unigue GUID to avoid collisions.
        //        todoItem.ResourceName = Guid.NewGuid().ToString();
        //    }

        //    // Send the item to be inserted. When blob properties are set this
        //    // generates an SAS in the response.
        //    await todoTable.InsertAsync(todoItem);

        //    // If we have a returned SAS, then upload the blob.
        //    if (!string.IsNullOrEmpty(todoItem.SasQueryString))
        //    {
        //        // Get the URI generated that contains the SAS 
        //        // and extract the storage credentials.
        //        StorageCredentials cred = new StorageCredentials(todoItem.SasQueryString);
        //        var imageUri = new Uri(todoItem.ImageUri);

        //        // Instantiate a Blob store container based on the info in the returned item.
        //        CloudBlobContainer container = new CloudBlobContainer(
        //            new Uri(string.Format("https://{0}/{1}",
        //                imageUri.Host, todoItem.ContainerName)), cred);

        //        // Get the new image as a stream.
        //        using (var inputStream = await media.OpenReadAsync())
        //        {
        //            // Upload the new image as a BLOB from the stream.
        //            CloudBlockBlob blobFromSASCredential =
        //                container.GetBlockBlobReference(todoItem.ResourceName);
        //            await blobFromSASCredential.UploadFromStreamAsync(inputStream);
        //        }

        //        // When you request an SAS at the container-level instead of the blob-level,
        //        // you are able to upload multiple streams using the same container credentials.

        //        await ResetCaptureAsync();
        //    }

        //    // Add the new item to the collection.
        //    items.Add(todoItem);
        //}

        //commented out
        private async Task InsertTodoItem(TodoItem todoItem)
        {
            // This code inserts a new TodoItem into the database. When the operation completes
            // and Mobile Services has assigned an Id, the item is added to the CollectionView
            await todoTable.InsertAsync(todoItem);
            items.Add(todoItem);
            todoItem.Id = string.Format("partition,{0}", Guid.NewGuid()); //added
            //await SyncAsync(); // offline sync
        }
コード例 #3
0
ファイル: MainPage.cs プロジェクト: groovyc/newproject
        private async Task UpdateCheckedTodoItem(TodoItem item)
        {
            // This code takes a freshly completed TodoItem and updates the database. When the MobileService 
            // responds, the item is removed from the list 
            await todoTable.UpdateAsync(item);
            items.Remove(item);
            ListItems.Focus(Windows.UI.Xaml.FocusState.Unfocused);

            //await SyncAsync(); // offline sync
        }