Beispiel #1
0
 public Models.TodoList Clone(Models.TodoList list)
 {
     return(Factory
            (
                null,
                list.Title,
                list.Items.Select(x => _todoItemRepository.Clone(x))
            ));
 }
        public TodoListViewModel(Models.TodoList list)
        {
            _todoItemRepository = new Repositories.TodoItemRepository();

            this.TodoList = list;
            foreach (var item in list.Items)
            {
                this.Items.Add(new ViewModels.TodoItemViewModel(item));
            }
        }
        public TodoListViewModel(Models.TodoList list)
        {
            this.TodoList = list;

            var repo      = TodoItemRepository.GetForToDoListId(list.Id);
            var todoItems = repo.GetAllItems();

            foreach (var item in todoItems)
            {
                this.Items.Add(new ViewModels.TodoItemViewModel(item));
            }
        }
        protected override async Task OnParametersSetAsync()
        {
            ListId ??= (await TodoListService.GetAllLists()).FirstOrDefault()?.Id;

            if (ListId == null)
            {
                var todoList = new Models.TodoList {
                    Name = "First Todo List"
                };
                await TodoListService.Add(todoList);

                ListId = todoList.Id;
            }

            TodoItems = new ObservableCollection <TodoItem>(await TodoItemService.GetList(ListId));
        }
Beispiel #5
0
        public int CreateTodoList(string userId, Models.TodoList todoListModel)
        {
            var todoListEntity = new TodoList
            {
                Title       = todoListModel.Title,
                UserId      = userId,
                CreatedTime = todoListModel.CreatedTime
            };

            using (_db)
            {
                _db.TodoLists.Add(todoListEntity);
                _db.SaveChanges();
            }

            return(todoListEntity.Id);
        }
Beispiel #6
0
 public void Update(Models.TodoList todoList)
 {
     TodoListService.Update(todoList);
 }
Beispiel #7
0
 public void Delete(Models.TodoList todoList)
 {
     TodoListService.Delete(todoList);
 }
Beispiel #8
0
 public async Task NewTodoList(Models.TodoList todoList)
 {
     await TodoListService.Add(todoList);
 }
Beispiel #9
0
 public void OnSubmit()
 {
     OnCreate.InvokeAsync(TodoList);
     TodoList = new Models.TodoList();
 }
Beispiel #10
0
 protected override void OnInitialized()
 {
     TodoList = new Models.TodoList();
 }
 public override void Prepare(Parameter parameter)
 {
     _list = parameter.List;
 }