Exemplo n.º 1
0
 /**
  * Updates an existing note item in azure
  */
 public async Task UpdateNoteAsync(NotesItem notesItem)
 {
     for (int i = 0; i < Items.Count; i++)
     {
         if ((Items[i].Id).Equals(notesItem.Id))
         {
             Items[i].Text = notesItem.Text;
         }
     }
     await notesTable.UpdateAsync(notesItem);
 }
Exemplo n.º 2
0
        /**
         * Inserts a new note item into azure
         */
        public async Task InsertTodoItemAsync(NotesItem notesItem)
        {
            try
            {
                await notesTable.InsertAsync(notesItem);

#if OFFLINE_SYNC_ENABLED
                await SyncAsync(); // Send changes to the mobile app backend.
#endif

                Items.Add(notesItem);
            }
            catch (MobileServiceInvalidOperationException e)
            {
                Console.Error.WriteLine(@"ERROR {0}", e.Message);
            }
        }
Exemplo n.º 3
0
        /**
         * Deleting an existing note item in azure
         */
        public async Task CompleteItemAsync(NotesItem item)
        {
            try
            {
                item.Delete = true;
                await notesTable.UpdateAsync(item);

#if OFFLINE_SYNC_ENABLED
                await SyncAsync(); // Send changes to the mobile app backend.
#endif

                Items.Remove(item);
            }
            catch (MobileServiceInvalidOperationException e)
            {
                Console.Error.WriteLine(@"ERROR {0}", e.Message);
            }
        }
Exemplo n.º 4
0
        /**
         * Actions that can occur after storyboard is loaded
         */
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();
            notesService = NotesService.DefaultService;
            await notesService.InitializeStoreAsync();

            //actions by clicking done button
            doneNotesButton.TouchUpInside += async(object sender, EventArgs e) =>
            {
                if (string.IsNullOrWhiteSpace(notesTextArea.Text))
                {
                    return;
                }

                if (!isInEditingMode)
                {
                    // new note
                    var newItem = new NotesItem
                    {
                        Text   = notesTextArea.Text,
                        Delete = false
                    };
                    await notesService.InsertTodoItemAsync(newItem);
                }
                else
                {
                    // note already exists and has to be updated in azure
                    note.Text = notesTextArea.Text;
                    await notesService.UpdateNoteAsync(note);

                    isInEditingMode = false;
                }

                notesTextArea.Text = "";
                await notesService.RefreshDataAsync();
            };
        }