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; } }
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 void Update(Task task) { using (var context = TasksContextFactory.Create(_connectionString)) { context.Update(task); context.SaveChanges(); } }
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; }
public Task Add(Task newTask) { using (var context = TasksContextFactory.Create(_connectionString)) { var task = context.Add(newTask); context.SaveChanges(); return task.Entity; } }
public static DbTask ToDbTask(Task task) { return new DbTask { Description = task.Description, Due = task.Due, IsDone = task.IsDone, Title = task.Title, Uid = task.GoogleId }; }
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 }; }
public void Update(Task task) { _db.Tasks.UpdateById(task); }
public Task Add(Task newTask) { return _db.Tasks.Insert(newTask); }
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(); } }
private static Task GetTask() { return s_foundTask ?? (s_foundTask = s_dao.FindById(s_addedTask.Id)); }
private static Task GetTask() { return foundTask ?? (foundTask = dao.FindById(addedTask.Id)); }
public TaskViewModel(int taskListId) { _taskListId = taskListId; _task = new Task(); Initialize(); }
public TaskViewModel(int taskId, int taskListId) { _taskListId = taskListId; _task = TaskContainer.GetTask(taskId); Initialize(); }