예제 #1
0
        public void ResolveLabels(TodoItem todoItem)
        {
            if (todoItem.Labels != null)
            {
                List <TodoLabel> tempList = new List <TodoLabel>(todoItem.Labels);
                foreach (TodoLabel label in todoItem.Labels)
                {
                    string    labelText = label.Value;
                    TodoLabel found     = _context.TodoItemLabels.FirstOrDefault(t => t.Value.Equals(labelText));
                    if (found != null)
                    {
                        tempList.Remove(label);
                        tempList.Add(found);
                        found.LabelTodoItems.Add(todoItem);
                    }
                    else
                    {
                        label.LabelTodoItems.Add(todoItem);
                        _context.TodoItemLabels.Add(label);
                    }
                }

                todoItem.Labels = tempList;
            }
        }
예제 #2
0
        public override bool Equals(object obj)
        {
            if (obj == null || this.GetType() != obj.GetType())
            {
                return(false);
            }

            TodoLabel other = (TodoLabel)obj;

            return(other.Value.Equals(this.Value));
        }