public async Task <SearchTodoResult> Search([FromQuery] int?userId = null, [FromQuery] string searchExpression = null)
        {
            var result = await repository.Search(userId, searchExpression);

            foreach (var todoItem in result.Items)
            {
                await cache.Set(todoItem);
            }

            return(result);
        }
Beispiel #2
0
        private async Task ensureTestDataExist(TodoItem itemToInsert)
        {
            var matches = await todosRepository.Search(itemToInsert.UserId, itemToInsert.Title);

            if (matches.Count != 0)
            {
                foreach (var existingItem in matches.Items)
                {
                    if (existingItem.Title == itemToInsert.Title)
                    {
                        return;
                    }
                }
            }

            await todosRepository.Insert(new CreateNewTodoRequest(itemToInsert.UserId, itemToInsert.Title, itemToInsert.Completed));
        }