Example #1
0
 private async Task DeleteToDoItemAsync(ToDoItemViewModel toDoItemViewModel)
 {
     if (await _pageService.DisplayAlertAsync("Delete", $"Are you sure you want to delete {toDoItemViewModel.Name}?", "Yes", "No"))
     {
         ToDoItems.Remove(toDoItemViewModel);
         await _toDoService.DeleteToDoItemAsync(toDoItemViewModel.Key);
     }
 }
Example #2
0
 private async Task ToggleToDoItemStateAsync(ToDoItemViewModel toDoItemViewModel)
 {
     toDoItemViewModel.IsComplete = !toDoItemViewModel.IsComplete;
     var toDoItem = new ToDoItem
     {
         Key        = toDoItemViewModel.Key,
         Name       = toDoItemViewModel.Name,
         IsComplete = toDoItemViewModel.IsComplete
     };
     await _toDoService.UpdateToDoItemStateAsync(toDoItem);
 }
Example #3
0
        public ToDoItemDetailViewModel(ToDoItemViewModel viewModel, IToDoService toDoService, IPageService pageService)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException(nameof(viewModel));
            }

            _toDoService = toDoService;
            _pageService = pageService;

            SaveCommand = new Command(async() => await SaveAsync());

            ToDoItem = new ToDoItem
            {
                Key        = Guid.NewGuid().ToString(),
                Name       = viewModel.Name,
                IsComplete = false
            };
        }