// [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));
        }
Exemple #2
0
        public void OnShowTodosButtonClicked()
        {
            _view.Busy(true);

            Items.AddRange(_todosService.GetTodos());
            _view.NotifyDataSetChanged();

            _view.Busy();
        }
        public async Task <ActionResult <IList <Todo> > > GetTodosAsync()
        {
            try
            {
                IList <Todo> todos = await service.GetTodos();

                return(Ok(todos));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }