Beispiel #1
0
        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);
        }
Beispiel #5
0
        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));
            }
        }
Beispiel #7
0
        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();
            }
        }
Beispiel #8
0
        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);
        }
Beispiel #10
0
        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);
                    }
                }
            }
        }
Beispiel #11
0
        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;
					}
				}
			}
		}
Beispiel #13
0
        void ITaskListTaskCollectionRepo.Add(ITaskListCore container,
		                                      ITaskCore item)
        {
            throw new NotSupportedException (
                "A task can only belong to one task list.");
        }
Beispiel #14
0
        string ITaskListRepository.UpdateName(ITaskListCore taskList,
		                                       string name)
        {
            throw new NotSupportedException (
                "Cannot change the name of a task list.");
        }
Beispiel #15
0
 bool ITaskListRepository.CanChangeName(ITaskListCore taskList)
 {
     return false;
 }
Beispiel #16
0
 string ITaskListRepository.UpdateName(ITaskListCore taskList,
                                       string name)
 {
     throw new NotSupportedException(
               "Cannot change the name of a task list.");
 }
Beispiel #17
0
 void TaskListTaskCollectionRepo.ClearAll(ITaskListCore container)
 {
     throw new NotImplementedException();
 }
Beispiel #18
0
        public void ClearAll(ITaskListCore taskList)
        {
            var dummyList = backend.GetTaskListBy(taskList.Id);

            dummyList.Tasks.Clear();
        }
Beispiel #19
0
        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);
        }
Beispiel #20
0
 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);
			}
		}
Beispiel #23
0
 public void Delete(ITaskListCore taskList)
 {
     throw new NotImplementedException();
 }
Beispiel #24
0
		public void Delete (ITaskListCore taskList)
		{
			throw new NotImplementedException ();
		}
Beispiel #25
0
 ITaskCore TaskListTaskCollectionRepo.GetBy(ITaskListCore container,
                                            string id)
 {
     throw new NotImplementedException();
 }
Beispiel #26
0
 void TaskListTaskCollectionRepo.Add(ITaskListCore container,
                                     ITaskCore item)
 {
     throw new NotSupportedException(
               "A task can only belong to one task list.");
 }
Beispiel #27
0
 void ITaskListTaskCollectionRepo.ClearAll(ITaskListCore container)
 {
     throw new NotImplementedException ();
 }
Beispiel #28
0
 public ITaskCore GetBy(ITaskListCore container, string id)
 {
     return(CreateTask(backend.GetTaskBy(id)));
 }
Beispiel #29
0
        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;
                }
            }
        }
Beispiel #30
0
 bool ITaskListRepository.CanChangeName(ITaskListCore taskList)
 {
     return(false);
 }
Beispiel #31
0
        ITaskCore ITaskListTaskCollectionRepo.GetBy(ITaskListCore container,
		                                             string id)
        {
            throw new NotImplementedException ();
        }
Beispiel #32
0
        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);
        }
Beispiel #33
0
 void IBackend.Delete(ITaskListCore taskList)
 {
     throw new NotImplementedException();
 }