private void AddItem(object title) { TodoItems.Add(new TodoItemViewModel { Title = title.ToString() }); }
public void onAddPressed(object sender, EventArgs e) { EditableTodo = new ToDoItem(); EditableTodo.SetMainWindow(this); TodosPanel.Children.Add(EditableTodo); TodoItems.Add(EditableTodo); }
private async Task LoadTodoList() { var todos = await _todoService.GetAll(); var pendingGroup = TodoItems.FirstOrDefault(t => t.State == TodoItemCompletedState.Pending); if (pendingGroup is null) { pendingGroup = new TodoItemsGroup(TodoItemCompletedState.Pending); } var completedGroup = TodoItems.FirstOrDefault(t => t.State == TodoItemCompletedState.Completed); if (completedGroup is null) { completedGroup = new TodoItemsGroup(TodoItemCompletedState.Completed); } var pending = todos.Where(t => !t.Completed).ToList(); pendingGroup.TodoItems.ReplaceRange(pending); var completed = todos.Where(t => t.Completed).ToList(); completedGroup.TodoItems.ReplaceRange(completed); TodoItems.Clear(); TodoItems.Add(pendingGroup); TodoItems.Add(completedGroup); }
async Task ExecuteFetchTodoItemsCommand() { if (IsBusy) { return; } IsBusy = true; IsRefreshing = false; try { TodoItems.Clear(); var todoItems = await todoItemService.GetAll(); foreach (var item in todoItems) { TodoItems.Add(item); } } catch (Exception ex) { // TODO: show alert Debug.WriteLine(ex); } finally { IsBusy = false; IsRefreshing = false; } }
private async Task Create() { var result = await TodoAppService.CreateAsync(NewTodoText); TodoItems.Add(result); NewTodoText = null; }
private void ProcessDocument(Document doc) { if (doc.Id.Contains("::")) { var doctype = doc.CurrentRevision.UserProperties["doctype"].ToString(); if (doctype == typeof(TodoList).Name.ToLower()) { if (!TodoItems.ContainsKey(doc.Id)) { TodoItems.Add(doc.Id, new ObservableCollection <TodoItem>()); } TodoLists.Update <TodoList>(doc.UserProperties["doc"]); } else if (doctype == typeof(TodoItem).Name.ToLower()) { var todo = Get <TodoItem>(doc.Id); if (!TodoItems.ContainsKey(todo.TodoListId)) { TodoItems.Add(todo.TodoListId, new ObservableCollection <TodoItem>()); } TodoItems[todo.TodoListId].Update <TodoItem>(todo); } } }
static TodoItemService() { TodoItems.Add(++_lastId, new TodoItem { ItemName = "Choose technology and programming language", IsItemComplete = true, ItemDetails = "Find the documentation and all the necessary materials", ItemId = _lastId }); TodoItems.Add(++_lastId, new TodoItem { ItemName = "Learn Asp.Net Core", IsItemComplete = false, ItemDetails = "Learn theory and practice new things", ItemId = _lastId }); TodoItems.Add(++_lastId, new TodoItem { ItemName = "Raise the level of knowledge in English", IsItemComplete = false, ItemDetails = "Read English literature and communicate with native speakers", ItemId = _lastId }); TodoItems.Add(++_lastId, new TodoItem { ItemName = "Prepare for an interview", IsItemComplete = false, ItemDetails = "Repeat all the material", ItemId = _lastId }); }
private async Task LoadTodoItemsAsync() { try { IsRefreshing = true; var itemsResult = await _repo.FetchItemsAsync <TodoItem>(); if (itemsResult.IsValid()) { TodoItems = itemsResult.ModelCollection.AsObservableCollection(); if (!TodoItems.Any()) { TodoItems.Add(new TodoItem { Text = "Ghost Item" }); } } } finally { IsRefreshing = false; } }
private void ApplyFilter() { TodoItems.Clear(); foreach (var item in TodoItemDisplayState.Value == TodoItemState.All ? todoItems : todoItems.Where(i => i.State.Value == TodoItemDisplayState.Value)) { TodoItems.Add(item); } }
public TodoItem AddTodoItem(string text) { var item = new TodoItem(this, text); TodoItems.Add(item); return(item); }
private async void OnRefreshCommandExecuted() { TodoItems.Clear(); foreach (var item in await _apiClient.GetTodoItemsAsync()) { TodoItems.Add(item); } }
public void AddTodoItemToList() { TodoItems.Add(new TodoItem() { Name = NewTodoItemName }); NewTodoItemName = string.Empty; toDoListService.Save(TodoItems); }
private void OnMoveToDoCommand(Card card) { if (!TodoItems.Contains(card)) { DoingItems.Remove(card); CompletedItems.Remove(card); TodoItems.Add(card); } _cardsManager.Save(TodoItems, DoingItems, CompletedItems); }
private async void AddItem(object todoItemValue) { TodoItem todoItem = todoItemValue as TodoItem; if (todoItem != null) { await repository.AddAsync(todoItem); TodoItems.Add(todoItem); } }
public IActionResult Create([FromBody] TodoItem item) { if (item == null) { return(HttpBadRequest()); } TodoItems.Add(item); return(CreatedAtRoute("GetTodo", new { controller = "Todo", id = item.Key }, item)); }
async Task AddTodoItem(TodoItem item) { try { var addedItem = await todoItemService.Create(item); TodoItems.Add(addedItem); } catch (Exception ex) { // TODO: show alert Debug.WriteLine(ex); } }
CreateTodoItem(TodoItemDto todoItemDto) { var todoItem = new TodoItem { Name = todoItemDto.Name, IsComplete = todoItemDto.IsComplete }; _context !.TodoItems.Add(todoItem); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetTodoItem), new { id = todoItemDto.Id }, ItemToDto(todoItem))); }
public ToDoItemStorage() { var todoItem1 = new TodoItem(); todoItem1.Id = TodoItems.Any() ? TodoItems.Keys.Max() + 1 : 1; todoItem1.Name = "Training Session"; todoItem1.IsComplete = false; TodoItems.Add(todoItem1.Id, todoItem1); var todoItem2 = new TodoItem(); todoItem2.Id = TodoItems.Keys.Max() + 1; todoItem2.Name = "Ali and Shahid will Practice"; todoItem2.IsComplete = false; TodoItems.Add(todoItem2.Id, todoItem2); }
public async Task GetTodoItems() { if (initialized) { return; } IEnumerable <TodoItem> todoItems = await repository.GetAllAsync(); foreach (TodoItem item in todoItems) { TodoItems.Add(item); } initialized = true; }
public TodoItemsListVm(ITodoItemsService todoItemsService) { this.todoItemsService = todoItemsService; // Firstly get all items, and after that watch to changes. todoItemsService.GetAll() .Select(items => items.Select(todoItem => new TodoItemVm(todoItem))) .Do(items => TodoItems.AddRange(items)) .SelectMany(_ => todoItemsService.TodoItemAdded) .Subscribe(todoItem => TodoItems.Add(new TodoItemVm(todoItem))); this.WhenAnyValue(x => x.SelectedTodoItem) .Where(todoItem => todoItem != null) .Select(todoItem => todoItem.Model) .SelectMany(todoItem => todoItemsService.SetCurrentTodoItem(todoItem)) .Subscribe(); }
public async Task LoadTasks() { if (!_connectivity.IsConnected) { await _dialogService.DisplayAlertAsync("", "No Internet!", "Ok"); return; } IsBusy = true; var query = _crudTodotTable.CreateQuery() .Skip(((Page - 1) * RecordPerPage)) .Take(RecordPerPage); try { if (Page > NumberPages) { IsBusy = false; return; } await _crudTodotTable.PullAsync("getinfoquery", query); var data = _crudTodotTable.ToList("getinfoquery"); var recordNumber = _crudTodotTable.RecordCount("getinfoquery"); NumberPages = (int)Math.Ceiling((double)recordNumber / RecordPerPage); foreach (var todoItem in data) { TodoItems.Add(todoItem); } Page++; } catch (Exception ex) { await _dialogService.DisplayAlertAsync("", ex.Message, "Ok"); } IsBusy = false; }
private void OnMoveToPriorCommand(Card card) { if (!TodoItems.Contains(card)) { if (DoingItems.Contains(card)) { DoingItems.Remove(card); TodoItems.Add(card); } else if (CompletedItems.Contains(card)) { CompletedItems.Remove(card); DoingItems.Add(card); } } _cardsManager.Save(TodoItems, DoingItems, CompletedItems); }
public void AddCurrentTodoContent() { if (string.IsNullOrWhiteSpace(TodoContent.Value)) { return; } var newTodoItem = new TodoItem(TodoContent.Value); newTodoItem.RemoveRequested += OnTodoItemRemoveRequested; newTodoItem.State.PropertyValueChanged += OnTodoItemStateChanged; todoItems.Add(newTodoItem); TodoItems.Add(newTodoItem); TodoContent.Value = string.Empty; UpdateAllTodoItemsCompletionState(); ApplyFilter(); }
public override void OnNavigatedTo(NavigationParameters parameters) { IsBusy = true; switch (parameters.GetNavigationMode()) { case NavigationMode.Back: if (parameters.ContainsKey("todoItem")) { TodoItems.Add(parameters.GetValue <TodoItem>("todoItem")); } break; case NavigationMode.New: TodoItems.AddRange(parameters.GetValues <string>("todo") .Select(n => new TodoItem { Name = n })); break; } IsBusy = false; }
private void RenderTodoItems() { foreach (ToDoTask task in repo.CurrentDate.Tasks) { ToDoItem tdi = new ToDoItem(task); tdi.SetMainWindow(this); tdi.TodoDescription.IsReadOnly = true; tdi.TodoName.IsReadOnly = true; tdi.TodoDescription.BorderThickness = new Thickness(0); tdi.TodoName.BorderThickness = new Thickness(0); tdi.DoneButton.Visibility = Visibility.Hidden; tdi.DeleteButton.Visibility = Visibility.Visible; if (tdi.TodoTask.IsDone) { tdi.TodoName.TextDecorations = TextDecorations.Strikethrough; tdi.TaskCheckBox.IsChecked = true; } tdi.TaskCheckBox.Visibility = Visibility.Visible; TodosPanel.Children.Add(tdi); TodoItems.Add(tdi); RenderActualDays(); } }
public void AddTodoItem() { _repository.SaveTask(NewTodoItem); TodoItems.Add(NewTodoItem); NewTodoItem = new TodoItem(); }
public override void OnNavigatedTo(NavigationParameters parameters) #endif { IsBusy = true; switch (parameters.GetNavigationMode()) { case NavigationMode.Back: #if (UseAzureMobileClient) #if (UseMvvmHelpers) TodoItems.ReplaceRange(await _dataContext.TodoItems.ReadAllItemsAsync()); #else Todoitems.Clear(); foreach (var item in await _dataContext.TodoItems.ReadAllItemsAsync()) { TodoItems.Add(item); } #endif #elseif (UseRealm) // Do anything you want to do only when Navigating Back to the View #else if (parameters.ContainsKey("todoItem")) { TodoItems.Add(parameters.GetValue <TodoItem>("todoItem")); } #endif break; case NavigationMode.New: #if (UseAzureMobileClient) #if (UsesAuthentication) await _cloudService.LoginAsync(); #endif #if (UseMvvmHelpers) TodoItems.AddRange(await _dataContext.TodoItems.ReadAllItemsAsync()); #else foreach (var item in await _dataContext.TodoItems.ReadAllItemsAsync()) { TodoItems.Add(item); } #endif #elseif (UseRealm) TodoItems = _realm.All <TodoItem>(); #else #if (UseMvvmHelpers) TodoItems.AddRange(parameters.GetValues <string>("todo") .Select(n => new TodoItem { Name = n })); #else foreach (var item in parameters.GetValues <string>("todo")) { TodoItems.Add(new TodoItem() { Name = item }); } #endif #endif break; } IsBusy = false; }
public void Handle(Core.Boundaries.Todo.Response response) { TodoItems.Add(response); }
public void AddTodoItem() { TodoItems.Add(NewTodoItem); NewTodoItem = new TodoItem(); }
void AddToDoItem() { TodoItems.Add(new TodoItem(NewToDoInputValue, false)); }