示例#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;
     }
 }