private async void ChangeItemStatusAsync(object arg) { var selectedToDoItem = arg as ToDoItem; if (selectedToDoItem != null) { bool isOldStatusValueDone = ToDoItems.Where(x => x.Id == selectedToDoItem.Id).FirstOrDefault().IsDone; string statusNameForQuestion; if (isOldStatusValueDone) { statusNameForQuestion = AppResource.ActiveText; } else { statusNameForQuestion = AppResource.DoneText; } if (await UserDialogs.Instance.ConfirmAsync($"{AppResource.AreYouSureMarkItemText} {statusNameForQuestion}?", AppResource.ChangeStatusText, AppResource.YesText, AppResource.CancelText)) { bool isNewStatusValueDone = !isOldStatusValueDone; ToDoItems.Where(x => x.Id == selectedToDoItem.Id).FirstOrDefault().IsDone = isNewStatusValueDone; if (ToDoItems != null) { _dataService.SaveOrUpdateToDoItemsAsync(ToDoItems.ToList()); } } } }
private async void RemoveItemAsync(object arg) { var selectedToDoItem = arg as ToDoItem; if (selectedToDoItem != null) { if (await UserDialogs.Instance.ConfirmAsync(AppResource.AreYouSureRemoveText, AppResource.RemoveText, AppResource.YesText, AppResource.CancelText)) { if (ToDoItems != null) { ToDoItems.Remove(ToDoItems.Where(x => x.Id == selectedToDoItem.Id).FirstOrDefault()); _dataService.SaveOrUpdateToDoItemsAsync(ToDoItems.ToList()); } } } }