Beispiel #1
0
        /// <summary>
        /// Removes an <see cref="iCalObject"/>-based component from all
        /// of the collections that this object may be contained in within
        /// the iCalendar.
        /// </summary>
        /// <param name="child"></param>
        public override void RemoveChild(iCalObject child)
        {
            base.RemoveChild(child);

            if (child is UniqueComponent)
            {
                UniqueComponents.Remove((UniqueComponent)child);
            }

            Type type = child.GetType();

            if (type == typeof(Event) || type.IsSubclassOf(typeof(Event)))
            {
                Events.Remove((Event)child);
            }
            else if (type == typeof(FreeBusy) || type.IsSubclassOf(typeof(FreeBusy)))
            {
                FreeBusy.Remove((FreeBusy)child);
            }
            else if (type == typeof(Journal) || type.IsSubclassOf(typeof(Journal)))
            {
                Journals.Remove((Journal)child);
            }
            else if (type == typeof(DDay.iCal.Components.TimeZone) || type.IsSubclassOf(typeof(DDay.iCal.Components.TimeZone)))
            {
                TimeZones.Remove((DDay.iCal.Components.TimeZone)child);
            }
            else if (type == typeof(Todo) || type.IsSubclassOf(typeof(Todo)))
            {
                Todos.Remove((Todo)child);
            }
        }
Beispiel #2
0
        public async Task Remove(Todo item)
        {
            if (item == null)
            {
                return;
            }

            //检查是否存在
            var data = LoadLogs(item.ProjcectId);
            var todo = data.Todos.FirstOrDefault(x => x.Id == item.Id);

            if (data.Logs.Count(x => x.TodoId == item.Id) > 0)
            {
                //项目不为空,跳过处理
                Console.WriteLine("项目不为空,不能删除。");
                return;
            }

            //移除项目
            Todos.Remove(todo);
            //移除索引
            DataIndex.Todos.Remove(item.Key);
            await Remove(todo.Key);
            await Save(DataIndex);

            MessageAction?.Invoke(MessageTypeUpdate);
        }
Beispiel #3
0
        /// <summary>
        /// Deletes a Todo-item from the collection.
        /// </summary>
        /// <param name="todo">The Todo-item to be deleted.</param>
        private async Task DeleteTodo(TodoViewModel todo)
        {
            if (todo == null)
                return;            

            // Delete item from database
            var success = await _repo.DeleteTodo(todo);

            // If failed, set message and return
            if (!success)
            {
                SetMessage("Deletion failed. Try again later.");
                return;                
            }

            // Reset selected item
            SelectedTodo = null;

            // Remove item from view
            Todos.Remove(todo);

            // Set message
            SetMessage("List deleted.");

            // Set as deleted todo
            DeletedTodo = todo;

            // Update todo order
            await UpdateTodoOrder();
        }
Beispiel #4
0
        public async void UpdateAsync()
        {
            await _todoService.UpdateTodo(SelectedItem);

            Todos.Remove(SelectedItem);
            Todos.Add(SelectedItem);
        }
Beispiel #5
0
        public Task <bool> Delete(string id)
        {
            var todo = Todos.FirstOrDefault(t => t.Id == id);

            if (todo != null)
            {
                Todos.Remove(todo);
            }
            return(Task.FromResult(todo != null));
        }
Beispiel #6
0
        public void Remove(int id)
        {
            var todo = Todos.FirstOrDefault(x => x.Id == id);

            if (todo == null)
            {
                throw new KeyNotFoundException();
            }

            Todos.Remove(todo);
        }
Beispiel #7
0
        private void Todo_DeleteRequested(object sender, EventArgs e)
        {
            var todo = sender as TodoViewModel;

            Debug.Assert(todo != null);

            TodoRepo.Delete(todo.Model);
            Todos.Remove(todo);

            MessengerInstance.Send(new NotificationMessage(Strings.EntryDeleted));
        }
        public async void DeleteToDo(TodoDto todo)
        {
            if (todo.Completed)
            {
                total_finished--;
            }
            total_todos--;
            Todos.Remove(todo);

            await ApiMethods.DeleteToDo(todo);
        }
        public void CanRemoveTodos()
        {
            var todos = new Todos();

            todos.Add("To-do 1");
            var countBeforeDelete = todos.Get().Count;
            var todo = todos.Get().Find(t => t.GetDescription().Equals("To-do 1"));

            todos.Remove(todo);
            Assert.Equal(1, countBeforeDelete);
            Assert.Empty(todos.Get());
        }
 public void DeleteRange(IEnumerable <Todo> todos)
 {
     foreach (var todo in todos)
     {
         if (todo.TodoComments != null)
         {
             foreach (var c in todo.TodoComments)
             {
                 TodoComments.Remove(c.Id);
             }
         }
         while (Todos.ContainsKey(todo.Id))
         {
             Todos.Remove(todo.Id);
         }
     }
 }
Beispiel #11
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);
             * });
             */
        }
Beispiel #12
0
        public static void DeleteTask(dynamic metadata, dynamic content)
        {
            var id        = content.Id.ToString();
            var groupKey  = metadata.GroupKey.ToString();
            var memberKey = metadata.MemberKey.ToString();
            var task      = FindById(metadata.GroupKey.ToString(), id);

            if (task != null)
            {
                Todos.Remove(task);

                var dataToSend = new { GroupKey = groupKey, MemberKey = memberKey, Id = id };
                if (task.Kind == TodoType.Task)
                {
                    SendFeedbackMessage(type: MsgType.Success, actionTime: GetCreateDate(metadata), action: MapAction.TaskFeedback.TaskDeleted.Name, content: dataToSend);
                }
            }
            else
            {
                //SendFeedbackMessage(type: FeedbackType.Error, groupKey: groupKey, id: id, content: "Cannot find task!", originalRequest: "CloseTask");
            }
        }
Beispiel #13
0
 public void RemoveTodo(TodoTask todo)
 {
     Todos.Remove(todo);
 }
 public void RemoveTodo(object sender, RoutedEventArgs eventArgs)
 {
     Todos.Remove(SelectedTodo);
 }
Beispiel #15
0
 private void DeleteTodo(Todo todo)
 {
     TodoRepository.Delete(todo);
     Todos.Remove(todo);
 }
Beispiel #16
0
        public async void DeleteAsync()
        {
            await _todoService.DeleteTodo(SelectedItem);

            Todos.Remove(SelectedItem);
        }