コード例 #1
0
        private void AddTodo_Click(object sender, RoutedEventArgs e)
        {
            //set default values to be added to todo collection
            int    userIDToPass = 1;
            var    lastTodo     = Todos.Last();
            int    lastTodoId   = lastTodo.id += 1;
            bool   newCompleted = false;
            string titleCreated = AddNewTodoField.Text;

            var newTodo = new Todo()
            {
                userId    = userIDToPass,
                id        = lastTodoId,
                title     = titleCreated,
                completed = newCompleted
            };

            //add to list of todos at the beginning of the list
            Todos.Insert(0, newTodo);

            //show new todo in details view
            SelectedTodo.Clear();
            SelectedTodo.Add(newTodo);

            //clear searhc field
            AddNewTodoField.Text = "";
        }
コード例 #2
0
ファイル: TodosController.cs プロジェクト: wangjun009xx/Oak
        public dynamic Create(dynamic @params)
        {
            todos.Insert(Todo(@params));

            return(Get(@params.Id));
        }