Esempio n. 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);
            }
        }
Esempio n. 2
0
        public string UpdateName(ITaskListCore taskList, string name)
        {
            var dummyList = backend.GetTaskListBy(taskList.Id);

            dummyList.ListName = name;
            return(name);
        }
Esempio n. 3
0
        public void Add(ITaskListCore taskList, ITaskCore task)
        {
            var dummyList = backend.GetTaskListBy(taskList.Id);
            var dummyTask = backend.GetTaskBy(task.Id);

            dummyList.Tasks.Add(dummyTask);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 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);
        }
Esempio n. 6
0
        public IEnumerable <ITaskCore> GetAll(ITaskListCore container)
        {
            var dummyList = backend.GetTaskListBy(container.Id);

            foreach (var dummyTask in dummyList.Tasks)
            {
                yield return(CreateTask(dummyTask));
            }
        }
Esempio n. 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();
            }
        }
Esempio n. 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);
        }
Esempio n. 9
0
        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);
        }
Esempio n. 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);
                    }
                }
            }
        }
Esempio n. 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);
                }
            }
        }
Esempio n. 12
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;
					}
				}
			}
		}
Esempio n. 13
0
        void ITaskListTaskCollectionRepo.Add(ITaskListCore container,
		                                      ITaskCore item)
        {
            throw new NotSupportedException (
                "A task can only belong to one task list.");
        }
Esempio n. 14
0
        string ITaskListRepository.UpdateName(ITaskListCore taskList,
		                                       string name)
        {
            throw new NotSupportedException (
                "Cannot change the name of a task list.");
        }
Esempio n. 15
0
 bool ITaskListRepository.CanChangeName(ITaskListCore taskList)
 {
     return false;
 }
Esempio n. 16
0
 string ITaskListRepository.UpdateName(ITaskListCore taskList,
                                       string name)
 {
     throw new NotSupportedException(
               "Cannot change the name of a task list.");
 }
Esempio n. 17
0
 void TaskListTaskCollectionRepo.ClearAll(ITaskListCore container)
 {
     throw new NotImplementedException();
 }
Esempio n. 18
0
        public void ClearAll(ITaskListCore taskList)
        {
            var dummyList = backend.GetTaskListBy(taskList.Id);

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