예제 #1
0
        public async Task GetTodos()
        {
            var optionsBuilder = new DbContextOptionsBuilder <TodosDbContext>()
                                 .UseSqlServer(CreateInMemoryDatabase());

            TodosDbContext TodosContext = new TodosDbContext(optionsBuilder.Options);
            TodosService   todosService = new TodosService(TodosContext);

            TodosContext.Todos.Add(new Todo());
            var obj = await todosService.GetTodos();

            Assert.IsNotNull(obj);
        }
예제 #2
0
        public ActionResult <IEnumerable <Todo> > Get(int limit, string search)
        {
            IEnumerable <Todo> todos = todosService.GetTodos();

            if (todos.Count() == 0)
            {
                return(NoContent());
            }

            if (search != null && search != "")
            {
                todos = todosService.Search(search, todos);
            }

            if (limit > 0)
            {
                todos = todos.TakeLast(limit);
            }

            return(Ok(new { todos }));
        }
예제 #3
0
 public async Task <IEnumerable <Todo> > Get()
 {
     return(await todos.GetTodos());
 }