Exemplo n.º 1
0
        public async Task <IActionResult> Index()
        {
            var coll = await _appService.ListarClientes();

            var list = coll.Select(c => c.ToViewModel()).ToList();

            return(View(list));
        }
        public async Task <IActionResult> Get(string q)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(q))
                {
                    return(Ok(await _service.ListarClientes()));
                }
                Expression <Func <Cliente, bool> > expression = x => x.Nome.Contains(q) || x.Cpf.Equals(q);
                var clientes = await _service.Procurar(expression);

                return(Ok(clientes));
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Erro ao pesquisar clientes");
                return(StatusCode(500, "Erro ao pesquisar clientes."));
            }
        }
 public void Should_show_results_if_list_different_zero()
 {
     var result = applicationService.ListarClientes();
     Assert.AreNotEqual(result.ToString().Length, 0);
 }