示例#1
0
        public ClienteDTO FindCliente(string nomeCliente)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(nomeCliente))
                {
                    throw new AppException("Informe o nome de cliente.");
                }

                var spec    = ClienteSpecification.ConsultaTexto(nomeCliente);
                var Cliente = _clienteRepository.AllMatching(spec).SingleOrDefault();
                if (Cliente == null)
                {
                    throw new AppException("Cliente não encontrado.");
                }

                var adapter = TypeAdapterFactory.CreateAdapter();
                return(adapter.Adapt <Cliente, ClienteDTO>(Cliente));
            }
            catch (Exception ex)
            {
                throw ManipuladorDeExcecao.TrateExcecao(ex);
            }
        }