public async Task <IActionResult> Index(string ordenar = "", string filtrar = "")
        {
            var todos = _mapper.Map <IEnumerable <TodoViewModel> >(await _todoAppService.Get());

            if (!String.IsNullOrEmpty(ordenar))
            {
                if (ordenar.TrimStart().TrimEnd() == "Data")
                {
                    todos = todos.OrderBy(x => x.CreateDate);

                    return(View(todos));
                }

                if (ordenar.TrimStart().TrimEnd() == "Categoria")
                {
                    todos = todos.OrderBy(x => x.Category.Description);

                    return(View(todos));
                }
                else
                {
                    return(View(todos));
                }
            }

            if (!String.IsNullOrEmpty(filtrar))
            {
                ViewData["SelectedFilter"] = filtrar;

                if (filtrar == "Created")
                {
                    todos = todos.Where(x => x.Status == 1).ToList();

                    return(View(todos));
                }

                if (filtrar == "Completed")
                {
                    todos = todos.Where(x => x.Status == 2).ToList();

                    return(View(todos));
                }

                if (filtrar == "Todos")
                {
                    return(View(todos));
                }
            }


            return(View(todos));
        }
示例#2
0
 public void Get()
 {
     _todoAppService.Get(42).ShouldBe("Compat-42-1.0");
 }
示例#3
0
 public void Get()
 {
     _todoAppService.Get(42).ShouldBe("42-2.0");
 }
示例#4
0
        public async Task <ActionResult <IEnumerable <Todo> > > Get()
        {
            var todos = _mapper.Map <IEnumerable <TodoViewModel> >(await _todoAppService.Get());

            return(Ok(todos));
        }