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())); }
public IActionResult List() { var items = _repository.List(ToDoItemSpecs.All()) .Select(ToDoItemDTO.FromToDoItem); return(Ok(items)); }
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); }
public void OnGet() { ToDoItems = _repository.List(ToDoItemSpecs.All()).ToList(); }