示例#1
0
        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);
        }
示例#2
0
        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;
        }
示例#3
0
        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();
        }