Exemple #1
0
        public async void Archive()
        {
            Todos.Where(x => x.Completed).ForEach(x => x.Archived = true);
            await _unitOfWork.CommitAsync();

            GetTodoItems();
        }
Exemple #2
0
 public static IEnumerable <TodoItem> GetTask(string member)
 {
     if (member == "All")
     {
         return(Todos);
     }
     return(Todos.Where(i => i.Status != TodoStatus.Close && (i.MemberKey ?? i.GroupKey) == member).OrderBy(t => t.Sequence));
 }
Exemple #3
0
        /// <summary>
        /// 加载项目数据(不加载日志条目)
        /// </summary>
        /// <param name="projectId"></param>
        /// <returns></returns>
        public ProjectData Load(string projectId)
        {
            var projectData = new ProjectData();

            projectData.Project = Projects.FirstOrDefault(x => x.Id == projectId);
            projectData.Todos   = Todos.Where(x => x.ProjcectId == projectId).ToList();
            return(projectData);
        }
Exemple #4
0
        private async Task LoadTodo()
        {
            using var db = await NewDb;
            var plist = Projects.Select(x => x.Key).ToList();

            Todos = db.Todos.Where(x => plist.Contains(x.ProjcectId)).ToList();
            IndexProject.Todos.AddRange(Todos.Where(x => string.IsNullOrWhiteSpace(x.ProjcectId)).Select(x => x.Key));
        }
Exemple #5
0
        public List <Todo> GetAll(Category?category = null)
        {
            if (category.HasValue)
            {
                return(Todos
                       .Where(x => x.Category == category.Value)
                       .ToList());
            }

            return(Todos);
        }
Exemple #6
0
        static void AddTaskAndChildrenRepeat(TodoItem task, string parentId, string date, int hours, string originalRepeatId, DateTimeOffset actionTime)
        {
            var ctask = task.Clone();

            ctask.ParentId         = parentId;
            ctask.Description     += date;
            ctask.Deadline         = task.Deadline?.AddHours(hours);
            ctask.Status           = TodoStatus.Active;
            ctask.OriginalRepeatId = originalRepeatId;
            AddTask(ctask, actionTime: actionTime);
            foreach (var child in Todos.Where(t => t.ParentId == task.Id).ToArray())
            {
                AddTaskAndChildrenRepeat(child, ctask.Id, date, hours, originalRepeatId, actionTime);
            }
        }
Exemple #7
0
        public static void RepeatTask(dynamic metadata, dynamic content)
        {
            var id = content.Id.ToString();
            var repeatIfAllClosed = bool.Parse(content.RepeatIfAllClosed?.ToString() ?? "false");
            var date    = DateTimeOffset.Parse(content.LastGeneratedTime.ToString());
            var hours   = int.Parse(content.Hours.ToString());
            var dateStr = " (" + date.Date.ToShortDateString() + ")";

            TodoItem task = Todos.FirstOrDefault(t => t.Id == id);

            if (task != null)
            {
                var shouldRepeat = !repeatIfAllClosed || !Todos.Where(t => (t.OriginalRepeatId == id || t.Id == id) && t.Status != TodoStatus.Close).Any();
                if (shouldRepeat)
                {
                    AddTaskAndChildrenRepeat(task, task.ParentId, dateStr, hours, id, actionTime: GetCreateDate(metadata));
                }
            }
        }
Exemple #8
0
        public void Subscribe()
        {
            MessagingCenter.Subscribe <NewTodoP, Tuple <string, Todo> >(this, "AddTodo", async(obj, todoTuple) =>
            {
                string todoListId = todoTuple.Item1;
                Todo todo         = todoTuple.Item2;

                if (Id == todoListId) // Id check is unecessary. Get rid of tuple
                {
                    Todos.Add(todo);
                }
                await DataStore.AddTodoAsync(todoListId, todo);
            });


            MessagingCenter.Subscribe <TodoP, string>(this, "DeleteTodo", async(obj, todoId) =>
            {
                var todo = Todos.Where((Todo arg) => arg.Id == todoId).FirstOrDefault();
                Todos.Remove(todo);
                await DataStore.DeleteTodoAsync(Id, todo);
            });

            /*
             * MessagingCenter.Subscribe<TodoP, string>(this, "ToggleTodoDone", async (obj, todoId) =>
             * {
             *  var todo = Todos.Where((Todo arg) => arg.Id == todoId).FirstOrDefault();
             *
             *  int todoIdx = Todos.IndexOf(todo);
             *
             *  Todos.Remove(todo);
             *
             *  todo.Done = !todo.Done;
             *
             *  Todos.Insert(todoIdx, todo);
             *
             *  await DataStore.ToggleTodoDoneAsync(Id, todoId);
             * });
             */
        }
Exemple #9
0
 public async Task Destroy(Todo todo)
 {
     Todos = Todos.Where(candidate => !candidate.Id.Equals(todo.Id)).ToList();
     await Inform();
 }
Exemple #10
0
 public async Task ClearCompleted()
 {
     Todos = Todos?.Where(todo => !todo.Completed).ToList();
     await Inform();
 }
Exemple #11
0
 public Task <IEnumerable <Todo> > Get(bool done = false)
 {
     return(Task.FromResult(Todos.Where(t => t.Done == done)));
 }
Exemple #12
0
 internal static IEnumerable <TodoItem> GetTaskWhenMoveToLocation(string groupKey, string tag)
 {
     return(Todos.Where(i => i.Status != TodoStatus.Close && (i.MemberKey ?? i.GroupKey) == groupKey && i.Locations.Any(l => l.IndexOf(tag) > -1)));
 }
Exemple #13
0
 internal static IEnumerable <TodoItem> GetTaskByGroupTag(string groupKey, string tag)
 {
     return(Todos.Where(i => i.Status != TodoStatus.Close && (i.MemberKey ?? i.GroupKey) == groupKey && i.Tags.Any(t => t.Value.Contains(tag))));
 }
Exemple #14
0
 public Todo GetTodo(int id)
 {
     return(Todos.Where(t => t.Id == id).FirstOrDefault());
 }
        public void Update(Todo todo)
        {
            Todo t = Todos.Where(x => x.Id.Equals(todo.Id)).Single();

            t.CopyFrom(todo);
        }
 public IEnumerable <Todo> GetTodos(Func <Todo, bool> lambda)
 {
     return(Todos.Where(lambda));
 }