public void AddItem(string taskName) { if (string.IsNullOrWhiteSpace(taskName)) throw new ArgumentException("Name is invalid", "taskName"); var newItem = new TodoItem { Id = _nextID++, Title = taskName }; _items.Add(newItem); }
public void MarkComplete(TodoItem item) { if (item == null) throw new ArgumentException("Item is invalid", "item"); var found = Items.Where(e => e.Id == item.Id).FirstOrDefault(); if (found == null) throw new Exception("item not found"); found.Complete = true; }
public void MarkComplete(TodoItem item) { if (item == null) throw new ArgumentException("Item is invalid", "item"); var table = DataContext.GetTable<SqlTodoItem>(); var found = table.Where(e => e.id == item.Id).FirstOrDefault(); if (found == null) throw new Exception("item not found"); found.complete = true; DataContext.SubmitChanges(); }