Пример #1
0
        public async Task <IActionResult> DoneAsync(int id)
        {
            var item = await _repository.FindAsync(id);

            await _repository.DoneAsync(item);

            return(new OkResult());
        }
Пример #2
0
        public async Task <ActionResult <TodoItemDto> > GetTodoItem(long id)
        {
            var todoItem = await _repo.FindAsync(id);

            if (todoItem is null)
            {
                return(NotFound());
            }
            var result = _mapper.Map <TodoItemDto>(todoItem);

            return(Ok(result));
        }
Пример #3
0
        public async Task Can_Find_A_Todo_Item()
        {
            //Given
            var collection = new Collection {
                Name = "A Collection"
            };
            var toBeFound = await Database.OnceAndSaveAsync(async db =>
            {
                collection.TodoItems.Add(new TodoItem {
                    Name = "Item1"
                });
                collection.TodoItems.Add(new TodoItem {
                    Name = "Item2"
                });
                await db.Collections.AddAsync(collection);
                return(collection.TodoItems.First());
            });

            //When
            var found = await Database.OnceAsync(async db =>
            {
                var repository = new TodoItemRepository(db);
                return(await repository.FindAsync(toBeFound.Id));
            });

            //Then
            Assert.Equal(toBeFound.Id, found.Id);
            Assert.Equal(toBeFound.Name, found.Name);
            Assert.Equal(collection.Id, found.Collection.Id);
            Assert.Equal(collection.Name, found.Collection.Name);
        }
Пример #4
0
 public async Task <TodoItem> ShowAsync(int id)
 {
     return(await _repository.FindAsync(id));
 }