public static DbTaskList ToDbTaskList(TaskList tasklist) { return new DbTaskList { Name = tasklist.Name, Uid = tasklist.GoogleId }; }
public TasksViewModel(int taskListId) { EditTaskCommand = new SimpleCommand(EditTask, CanEditTask); NewTaskCommand = new SimpleCommand(NewTask); Tasks = new ObservableCollection<Task>(); TaskContainer.GetTasksForTaskList(taskListId).ForEach(p => Tasks.Add(p)); _taskList = TaskContainer.GetTaskList(taskListId); }
public async Task<ModelTask> AddTaskToTaskList(ModelTask task, TaskList taskList) { using (var service = await GetTaskService()) { var addedTask = await service.Tasks.Insert(TaskAdapter.ToGoogleTask(task), taskList.GoogleId).ExecuteAsync(); return TaskAdapter.ToModelTask(addedTask); } }
public async Task<List<ModelTask>> GetTasksForTaskList(TaskList taskList) { try { using (var service = await GetTaskService()) { var tasks = await service.Tasks.List(taskList.GoogleId).ExecuteAsync(); return tasks.Items.Select(TaskAdapter.ToModelTask).ToList(); } } catch (Exception) { return new List<ModelTask>(); } }
public void SaveTaskList(TaskList taskList) { using (var context = GetContext()) { DbTaskList dbTaskList; if (string.IsNullOrEmpty(taskList.GoogleId)) { dbTaskList = context.TaskLists.FirstOrDefault(p => p.Id == taskList.DbId); } else { dbTaskList = context.TaskLists.FirstOrDefault(p => p.Uid == taskList.GoogleId); } if (dbTaskList == null) { dbTaskList = TaskListAdapter.ToDbTaskList(taskList); context.TaskLists.InsertOnSubmit(dbTaskList); } else { dbTaskList.Name = taskList.Name; } context.SubmitChanges(); taskList.DbId = dbTaskList.Id; } }