Beispiel #1
0
        // [Route("/api/v1/[controller]/GetAll")]
        // [Route("/api/v1/[controller]")]
        public async Task <IActionResult> GetTodos([FromQuery] string category, [FromQuery] bool archived)
        {
            var user = User;

            _logger.LogInformation($"GET todos category : {category} archived : {archived}");
            List <Todo> todos;

            if (category != null)
            {
                todos = await _todosService.GetTodos(category, SortingType.TimeDESC);
            }
            else
            if (archived)
            {
                todos = await _todosService.GetArchivedTodos();
            }
            else
            {
                todos = await _todosService.GetTodos();
            }

            //return Ok(_mapper.Map<List<TodoView>>(todos));
            var todoViews = new List <TodoView>();

            foreach (var item in todos)
            {
                todoViews.Add(_mapper.Map <TodoView>(item));
            }
            return(Ok(todoViews));
        }