예제 #1
0
 public static DbTaskList ToDbTaskList(TaskList tasklist)
 {
     return new DbTaskList
     {
         Name = tasklist.Name,
         Uid = tasklist.GoogleId
     };
 }
예제 #2
0
 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);
 }
예제 #3
0
 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);
     }
 }
예제 #4
0
 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>();
     }
 }
예제 #5
0
 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;
     }
 }