Пример #1
0
        /// <summary>
        /// The delete async method
        /// Deletes the current note following validation and closes the note page
        /// </summary>
        /// <returns>A task to delete the current note following validation and close the note page</returns>
        private async Task DeleteAsync()
        {
            //Bypass the validation check if set by the AppSettings
            if (AppSettings.RequireDeleteCheck)
            {
                string promptResult = await DisplayPopupHelpers
                                      .ShowPromptAsync("Validation",
                                                       "To delete this note, enter it's title");

                if (promptResult == null)
                {
                    return;
                }

                if (promptResult != Title)
                {
                    await DisplayPopupHelpers
                    .ShowOKDialogAsync("Incorrect",
                                       "Your note has not been deleted");

                    return;
                }
            }

            if (IOHelpers.NoteExists(CurrentNote.Filename))
            {
                IOHelpers.DeleteNote(CurrentNote.Filename);
                await DisplayPopupHelpers
                .ShowOKDialogAsync("Deleted",
                                   "Your note has been deleted");
            }
            else
            {
                await DisplayPopupHelpers
                .ShowOKDialogAsync("Error",
                                   "The file could not be found; your note has not been deleted");
            }

            await NavigationHelpers.PopCurrentPageAsync();
        }