示例#1
0
 public void SaveTask(Task task, int taskListId)
 {
     using (var context = GetContext())
     {
         DbTask dbTask;
         if (string.IsNullOrEmpty(task.GoogleId))
         {
             dbTask = context.Tasks.FirstOrDefault(p => p.Id == task.DbId);
         }
         else
         {
             dbTask = context.Tasks.FirstOrDefault(p => p.Uid == task.GoogleId);
         }
         if (dbTask == null)
         {
             dbTask = TaskAdapter.ToDbTask(task);
             dbTask.TaskListId = taskListId;
             context.Tasks.InsertOnSubmit(dbTask);
         }
         else
         {
             dbTask.Description = task.Description;
             dbTask.Due = task.Due;
             dbTask.IsDone = task.IsDone;
             dbTask.Title = task.Title;
             dbTask.TaskListId = taskListId;
         }
         context.SubmitChanges();
         task.DbId = dbTask.Id;
     }
 }
示例#2
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);
     }
 }
示例#3
0
 public void Update(Task task)
 {
     using (var context = TasksContextFactory.Create(_connectionString))
     {
         context.Update(task);
         context.SaveChanges();
     }
 }
示例#4
0
 public static Link Create(Task task, string hostName)
 {
     var link = new Link
     {
         Rel = "item",
         HRef = string.Format("http://{0}/{1}/{2}", hostName, "task", task.Id)
     };
     return link;
 }
示例#5
0
        public Task Add(Task newTask)
        {
            using (var context = TasksContextFactory.Create(_connectionString))
            {
                var task = context.Add(newTask);
                context.SaveChanges();

                return task.Entity;
            }
        }
示例#6
0
 public static DbTask ToDbTask(Task task)
 {
     return new DbTask
     {
         Description = task.Description,
         Due = task.Due,
         IsDone = task.IsDone,
         Title = task.Title,
         Uid = task.GoogleId
     };
 }
示例#7
0
 public static TaskListItemModel Create(Task task, string hostName)
 {
     var hRef = string.Format("http://{0}/{1}/{2}", hostName, "task", task.Id);
     return new TaskListItemModel
     {
         HRef = hRef,
         Self = new Link { Rel = "item", HRef = hRef },
         Name = task.TaskName,
         Description = task.TaskDescription,
         IsComplete = task.CompletionDate.HasValue,
         CompletionDate = task.CompletionDate.ToDisplayString(),
         DueDate = task.DueDate.ToDisplayString(),
         Id = task.Id
     };
 }
示例#8
0
 public void Update(Task task)
 {
     _db.Tasks.UpdateById(task);
 }
示例#9
0
 public Task Add(Task newTask)
 {
     return _db.Tasks.Insert(newTask);
 }
示例#10
0
 public void UpdateGoogleIdForTask(Task task, string newGoogleId)
 {
     using (var context = GetContext())
     {
         var dbTask = context.Tasks.First(p => p.Id == task.DbId);
         dbTask.Uid = newGoogleId;
         context.SubmitChanges();
     }
 }
示例#11
0
 private static Task GetTask()
 {
     return s_foundTask ?? (s_foundTask = s_dao.FindById(s_addedTask.Id));
 }
示例#12
0
 private static Task GetTask()
 {
     return foundTask ?? (foundTask = dao.FindById(addedTask.Id));
 }
示例#13
0
 public TaskViewModel(int taskListId)
 {
     _taskListId = taskListId;
     _task = new Task();
     Initialize();
 }
示例#14
0
 public TaskViewModel(int taskId, int taskListId)
 {
     _taskListId = taskListId;
     _task = TaskContainer.GetTask(taskId);
     Initialize();
 }