コード例 #1
0
        public static async Task <int> PopulateDatabaseAsync(IRepository todoRepository)
        {
            if ((await todoRepository.CountAsync(ToDoItemSpecs.All())) >= 5)
            {
                return(0);
            }

            todoRepository.Add(new ToDoItem
            {
                Title       = "Get Sample Working",
                Description = "Try to get the sample to build."
            });
            todoRepository.Add(new ToDoItem
            {
                Title       = "Review Solution",
                Description = "Review the different projects in the solution and how they relate to one another."
            });
            todoRepository.Add(new ToDoItem
            {
                Title       = "Run and Review Tests",
                Description = "Make sure all the tests run and review what they are doing."
            });

            return(await todoRepository.CountAsync(ToDoItemSpecs.All()));
        }
コード例 #2
0
        public IActionResult List()
        {
            var items = _repository.List(ToDoItemSpecs.All())
                        .Select(ToDoItemDTO.FromToDoItem);

            return(Ok(items));
        }
コード例 #3
0
        public async Task AddsItemAndSetsId()
        {
            var repository = GetRepository();
            var item       = new ToDoItemBuilder().Build();

            repository.Add(item);
            _dbContext.SaveChanges();

            var newItem = await repository.FirstOrDefaultAsync(ToDoItemSpecs.All());

            Assert.Equal(item, newItem);
            Assert.True(newItem?.Id > 0);
        }
コード例 #4
0
 public void OnGet()
 {
     ToDoItems = _repository.List(ToDoItemSpecs.All()).ToList();
 }