void TaskListTaskCollectionRepo.AddNew(ITaskListCore container, ITaskCore item) { var command = "INSERT INTO Tasks" + "(Name, DueDate, CompletionDate, Priority, State, " + "Category, ExternalID) " + "VALUES (@name, @dueDate, @completionDate, " + "@priority, @state, @catId, ''); " + "SELECT last_insert_rowid();"; using (var cmd = new SqliteCommand(database.Connection)) { cmd.CommandText = command; cmd.Parameters.AddWithValue("@name", item.Text); cmd.Parameters.AddWithValue("@dueDate", Database.FromDateTime(item.DueDate)); cmd.Parameters.AddWithValue("@completionDate", Database.FromDateTime(DateTime.MinValue)); cmd.Parameters.AddWithValue("@priority", (int)item.Priority); cmd.Parameters.AddWithValue("@state", (int)item.State); cmd.Parameters.AddWithValue("@catId", int.Parse(container.Id)); var id = cmd.ExecuteScalar().ToString(); item.SetId(id); } }
public string UpdateName(ITaskListCore taskList, string name) { var dummyList = backend.GetTaskListBy(taskList.Id); dummyList.ListName = name; return(name); }
public void Add(ITaskListCore taskList, ITaskCore task) { var dummyList = backend.GetTaskListBy(taskList.Id); var dummyTask = backend.GetTaskBy(task.Id); dummyList.Tasks.Add(dummyTask); }
public void Remove(ITaskListCore taskList, ITaskCore task) { var dummyList = backend.GetTaskListBy(taskList.Id); var dummyTask = dummyList.Tasks.Single( t => t.Id.ToString() == task.Id); dummyList.Tasks.Remove(dummyTask); }
void ITaskListTaskCollectionRepo.Remove(ITaskListCore container, ITaskCore item) { string taskSeriesId, taskId; backend.DecodeTaskId(item, out taskSeriesId, out taskId); backend.Rtm.TasksDelete(backend.Timeline, container.Id, taskSeriesId, taskId); }
public IEnumerable <ITaskCore> GetAll(ITaskListCore container) { var dummyList = backend.GetTaskListBy(container.Id); foreach (var dummyTask in dummyList.Tasks) { yield return(CreateTask(dummyTask)); } }
void TaskListTaskCollectionRepo.Remove(ITaskListCore container, ITaskCore item) { var command = "DELETE FROM Tasks WHERE ID=@id;"; using (var cmd = new SqliteCommand(database.Connection)) { cmd.CommandText = command; cmd.Parameters.AddWithValue("@id", int.Parse(item.Id)); cmd.ExecuteNonQuery(); } }
void ITaskListTaskCollectionRepo.AddNew(ITaskListCore container, ITaskCore item) { var list = backend.Rtm.TasksAdd( backend.Timeline, item.Text, container.Id); var taskSeries = list.TaskSeriesCollection [0]; var last = taskSeries.TaskCollection.Length - 1; var id = backend.EncodeTaskId( taskSeries.TaskID, taskSeries.TaskCollection [last].TaskID); item.SetId(id); }
public void AddNew(ITaskListCore taskList, ITaskCore task) { var dummyList = backend.GetTaskListBy(taskList.Id); var dummyTask = new DummyTask(task.Text) { DueDate = task.DueDate == DateTime.MaxValue ? DateTime.MinValue : task.DueDate, Priority = (int)task.Priority }; dummyList.Tasks.Add(dummyTask); }
IEnumerable <ITaskCore> TaskListTaskCollectionRepo.GetAll( ITaskListCore container) { var command = "SELECT ID, Name, DueDate, CompletionDate, Priority, State " + "FROM Tasks WHERE Category=@id;"; using (var cmd = new SqliteCommand(database.Connection)) { cmd.CommandText = command; cmd.Parameters.AddIdParameter(container); using (var dataReader = cmd.ExecuteReader()) { while (dataReader.Read()) { var id = dataReader.GetInt32(0).ToString(); var name = dataReader.GetString(1); var state = (TaskState)dataReader.GetInt32(5); var completionDate = Database.ToDateTime(dataReader.GetInt64(3)); ITaskCore task; if (state == TaskState.Active) { task = backend.Factory.CreateTask(id, name); } else if (state == TaskState.Completed) { task = backend.Factory.CreateCompletedTask( id, name, completionDate); } else { task = backend.Factory.CreateDiscardedTask( id, name); } task.Priority = (TaskPriority)dataReader.GetInt32(4); task.DueDate = Database.ToDateTime(dataReader.GetInt64(2)); yield return(task); } } } }
IEnumerable <ITaskCore> ITaskListTaskCollectionRepo.GetAll( ITaskListCore container) { var tasks = backend.Rtm.TasksGetList(container.Id); foreach (var rtmList in tasks.ListCollection) { if (rtmList.TaskSeriesCollection == null) { continue; } foreach (var rtmTaskSeries in rtmList.TaskSeriesCollection) { var last = rtmTaskSeries.TaskCollection.Length - 1; var rtmTask = rtmTaskSeries.TaskCollection [last]; var taskId = backend.EncodeTaskId(rtmTaskSeries.TaskID, rtmTask.TaskID); ITaskCore task; if (rtmTask.Completed == DateTime.MinValue) { task = backend.Factory.CreateTask( taskId, rtmTaskSeries.Name); } else { task = backend.Factory.CreateCompletedTask( taskId, rtmTaskSeries.Name, rtmTask.Completed); } task.DueDate = rtmTask.Due; task.Priority = rtmTask.GetTaskPriority(); CacheNotes(rtmTaskSeries); yield return(task); } } }
IEnumerable<ITaskCore> TaskListTaskCollectionRepo.GetAll ( ITaskListCore container) { var command = "SELECT ID, Name, DueDate, CompletionDate, Priority, State " + "FROM Tasks WHERE Category=@id;"; using (var cmd = new SqliteCommand (database.Connection)) { cmd.CommandText = command; cmd.Parameters.AddIdParameter (container); using (var dataReader = cmd.ExecuteReader ()) { while (dataReader.Read ()) { var id = dataReader.GetInt32 (0).ToString (); var name = dataReader.GetString (1); var state = (TaskState)dataReader.GetInt32 (5); var completionDate = Database.ToDateTime (dataReader.GetInt64 (3)); ITaskCore task; if (state == TaskState.Active) task = backend.Factory.CreateTask (id, name); else if (state == TaskState.Completed) { task = backend.Factory.CreateCompletedTask ( id, name, completionDate); } else { task = backend.Factory.CreateDiscardedTask ( id, name); } task.Priority = (TaskPriority)dataReader.GetInt32 (4); task.DueDate = Database.ToDateTime (dataReader.GetInt64 (2)); yield return task; } } } }
void ITaskListTaskCollectionRepo.Add(ITaskListCore container, ITaskCore item) { throw new NotSupportedException ( "A task can only belong to one task list."); }
string ITaskListRepository.UpdateName(ITaskListCore taskList, string name) { throw new NotSupportedException ( "Cannot change the name of a task list."); }
bool ITaskListRepository.CanChangeName(ITaskListCore taskList) { return false; }
string ITaskListRepository.UpdateName(ITaskListCore taskList, string name) { throw new NotSupportedException( "Cannot change the name of a task list."); }
void TaskListTaskCollectionRepo.ClearAll(ITaskListCore container) { throw new NotImplementedException(); }
public void ClearAll(ITaskListCore taskList) { var dummyList = backend.GetTaskListBy(taskList.Id); dummyList.Tasks.Clear(); }
void ITaskListTaskCollectionRepo.AddNew(ITaskListCore container, ITaskCore item) { var list = backend.Rtm.TasksAdd ( backend.Timeline, item.Text, container.Id); var taskSeries = list.TaskSeriesCollection [0]; var last = taskSeries.TaskCollection.Length - 1; var id = backend.EncodeTaskId ( taskSeries.TaskID, taskSeries.TaskCollection [last].TaskID); item.SetId (id); }
public bool CanChangeName(ITaskListCore taskList) { return(true); }
void TaskListTaskCollectionRepo.Remove (ITaskListCore container, ITaskCore item) { var command = "DELETE FROM Tasks WHERE ID=@id;"; using (var cmd = new SqliteCommand (database.Connection)) { cmd.CommandText = command; cmd.Parameters.AddWithValue ("@id", int.Parse (item.Id)); cmd.ExecuteNonQuery (); } }
void TaskListTaskCollectionRepo.AddNew (ITaskListCore container, ITaskCore item) { var command = "INSERT INTO Tasks" + "(Name, DueDate, CompletionDate, Priority, State, " + "Category, ExternalID) " + "VALUES (@name, @dueDate, @completionDate, " + "@priority, @state, @catId, ''); " + "SELECT last_insert_rowid();"; using (var cmd = new SqliteCommand (database.Connection)) { cmd.CommandText = command; cmd.Parameters.AddWithValue ("@name", item.Text); cmd.Parameters.AddWithValue ("@dueDate", Database.FromDateTime (item.DueDate)); cmd.Parameters.AddWithValue ("@completionDate", Database.FromDateTime (DateTime.MinValue)); cmd.Parameters.AddWithValue ("@priority", (int)item.Priority); cmd.Parameters.AddWithValue ("@state", (int)item.State); cmd.Parameters.AddWithValue ("@catId", int.Parse (container.Id)); var id = cmd.ExecuteScalar ().ToString (); item.SetId (id); } }
public void Delete(ITaskListCore taskList) { throw new NotImplementedException(); }
public void Delete (ITaskListCore taskList) { throw new NotImplementedException (); }
ITaskCore TaskListTaskCollectionRepo.GetBy(ITaskListCore container, string id) { throw new NotImplementedException(); }
void TaskListTaskCollectionRepo.Add(ITaskListCore container, ITaskCore item) { throw new NotSupportedException( "A task can only belong to one task list."); }
void ITaskListTaskCollectionRepo.ClearAll(ITaskListCore container) { throw new NotImplementedException (); }
public ITaskCore GetBy(ITaskListCore container, string id) { return(CreateTask(backend.GetTaskBy(id))); }
IEnumerable<ITaskCore> ITaskListTaskCollectionRepo.GetAll( ITaskListCore container) { var tasks = backend.Rtm.TasksGetList (container.Id); foreach (var rtmList in tasks.ListCollection) { if (rtmList.TaskSeriesCollection == null) continue; foreach (var rtmTaskSeries in rtmList.TaskSeriesCollection) { var last = rtmTaskSeries.TaskCollection.Length - 1; var rtmTask = rtmTaskSeries.TaskCollection [last]; var taskId = backend.EncodeTaskId (rtmTaskSeries.TaskID, rtmTask.TaskID); ITaskCore task; if (rtmTask.Completed == DateTime.MinValue) { task = backend.Factory.CreateTask ( taskId, rtmTaskSeries.Name); } else { task = backend.Factory.CreateCompletedTask ( taskId, rtmTaskSeries.Name, rtmTask.Completed); } task.DueDate = rtmTask.Due; task.Priority = rtmTask.GetTaskPriority (); CacheNotes (rtmTaskSeries); yield return task; } } }
bool ITaskListRepository.CanChangeName(ITaskListCore taskList) { return(false); }
ITaskCore ITaskListTaskCollectionRepo.GetBy(ITaskListCore container, string id) { throw new NotImplementedException (); }
void ITaskListTaskCollectionRepo.Remove(ITaskListCore container, ITaskCore item) { string taskSeriesId, taskId; backend.DecodeTaskId (item, out taskSeriesId, out taskId); backend.Rtm.TasksDelete (backend.Timeline, container.Id, taskSeriesId, taskId); }
void IBackend.Delete(ITaskListCore taskList) { throw new NotImplementedException(); }