private void OnTaskItemTest(object sender, TaskItemViewModel vm)
        {
            var index = TaskItemViewModels.IndexOf(vm);

            if (index >= 0)
            {
                TaskItemViewModels[index] = vm;
            }
        }
        public IActionResult Create()
        {
            TaskItemViewModels taskItemViewModels = new TaskItemViewModels();

            taskItemViewModels.ListCategories = ICategoryService.FindAll().Select(t => new SelectListItem()
            {
                Text  = t.Name,
                Value = t.ID.ToString()
            }).ToList();
            return(View(taskItemViewModels));
        }
Beispiel #3
0
        public void SaveTask()
        {
            var task = new TaskItem
            {
                Title      = NewTaskTitle,
                TaskListId = TaskList.Id
            };

            var dbTask = DbManager.Instance.InsertEntity(task);

            TaskItemViewModels.Add(new TaskItemVm(dbTask));
            NewTaskTitle = string.Empty;
        }
        private void ResetTaskItemVm(TaskItemViewModel vmToReset)
        {
            var index = TaskItemViewModels.IndexOf(vmToReset);

            if (index < 0)
            {
                return;            // just to be safe
            }
            var task  = DbManager.Instance.GetEntityById <TaskItem>(vmToReset.TaskItem.Id);
            var newVm = GetTaskItemVm(task);

            TaskItemViewModels[index] = newVm;
        }
        // Event handlers

        private void OnTaskItemUpdated(dynamic sender, TaskItem taskItem)
        {
            try
            {
                var index = TaskItemViewModels.IndexOf(sender);
                if (index >= 0)
                {
                    TaskItemViewModels[index] = GetTaskItemVm(taskItem);
                }
            }
            catch (RuntimeBinderException ex)
            {
                Debug.WriteLine($"on task item updated: {ex}");
            }
        }
Beispiel #6
0
 public void ClearTaskItems()
 {
     TaskItemViewModels.Clear();
     DbManager.Instance.DeleteTaskListAndReferences(TaskList, false);
 }
 private void OnTaskItemDeleted(object sender, TaskItemViewModel taskItemVm)
 {
     TaskItemViewModels.Remove(taskItemVm);
 }
 public Task ClearAllTaskItemsAsync()
 {
     TaskItemViewModels.Clear();
     return(Task.Run(() => DbManager.Instance.DeleteTaskListAndReferences(TaskList, false))); // Keeping the list not its children
 }