Пример #1
0
        public async Task<IActionResult> Index()
        {
            var currentUser = await _userManager.FindByNameAsync(User.Identity.Name);
            var todoList = _todoListService.GetAllTodoListByUserId(currentUser.Id).ToList();

            var todoListViewModel = todoList.Select(t => new TodoListViewModel
            {
                Id = t.Id,
                Name = t.Name,
                Items = _itemService.GetAllItemsByTodoListId(t.Id).Select(i => new ItemViewModel
                {
                    Id = i.Id,
                    Name = i.Name,
                    Description = i.Description,
                    Status = i.Status
                })
            });

            var homeIndexViewModel = new HomeIndexViewModel { TodoList = todoListViewModel };

            return View(homeIndexViewModel);
        }