예제 #1
0
        // GET api/<TodoListController>/5
        public async Task <IActionResult> Get(int id, [FromQuery] string search, [FromQuery] bool undone)
        {
            var todoList = await this.db.TodoLists.Include(a => a.Items)
                           .SingleOrDefaultAsync(a => a.Id == id);

            if (todoList == null)
            {
                return(NotFound());
            }

            var todoItemVM = todoList.Items.Where(item => (string.IsNullOrWhiteSpace(search) ||
                                                           item.Name.ToLower()
                                                           .Contains(search
                                                                     .ToLower())) && (!undone || !item.Completed))
                             .Select(a => new TodoItemVM()
            {
                Id            = a.Id,
                Name          = a.Name,
                CompletedTask = a.Completed,
                CreateDate    = a.CreateDate
            }).ToList();

            var todoListVM = new TodoListVM()
            {
                Id    = todoList.Id,
                Name  = todoList.Name,
                Items = todoItemVM
            };

            return(Ok(todoListVM));
        }
예제 #2
0
        public NewTodoP(TodoListVM todoListVM)
        {
            InitializeComponent();

            TodoListVM = todoListVM;

            Todo = new Todo
            {
                Id          = Guid.NewGuid().ToString(),
                Title       = "Item name",
                Description = "This is an item description."
            };

            BindingContext = this;
        }
예제 #3
0
        public TodoListP()
        {
            InitializeComponent();

            var todoList = new TodoList
            {
                Title = "Title",
                Todos = new List <Todo>()
                {
                    new Todo {
                        Id = Guid.NewGuid().ToString(), Title = "TODOLIST 1 First item", Description = "This is an item description."
                    },
                }
            };

            BindingContext = TodoListVM = new TodoListVM(todoList);
        }
예제 #4
0
        public TodoListP(TodoListVM viewModel)
        {
            InitializeComponent();

            BindingContext = this.TodoListVM = viewModel;
        }