//[Route("listar-clientes")] public ActionResult Index() { try { var clienteViewModel = Mapper.Map <IList <GDC_Clientes>, IList <Cliente> >(_clienteRepository.ObterTodos()); foreach (Cliente cliente in clienteViewModel) { cliente.Venda = Mapper.Map <Venda>(_vendaRepository.ObterTodos() .Where(c => c.IdCliente == cliente.Id).FirstOrDefault()); cliente.Custom = Mapper.Map <Performance>(_customRepository.ObterTodos() .Where(c => c.IdCliente == cliente.Id).FirstOrDefault()); } return(View(clienteViewModel)); } catch { return(RedirectToAction("Error", "Base")); } }
public ActionResult Create() { CadastrarVendaViewModel vendaViewModel = new CadastrarVendaViewModel(); vendaViewModel.Clientes = Mapper.Map <IList <GDC_Clientes>, IList <Cliente> >(_clienteRepository.ObterTodos()); vendaViewModel.FormasDePagamentos = new List <FormaDePagamento>().OrderBy(a => a.Modelo).ToList(); vendaViewModel.Veiculos = Mapper.Map <IList <GDC_Veiculos>, IList <Veiculo> >(_veiculoRepository.ObterTodos()); vendaViewModel.Performance = Mapper.Map <IList <GDC_Perfomances>, IList <Performance> >(_perfomanceRepository.ObterTodos()); vendaViewModel.Endereco = new Endereco(); return(View(vendaViewModel)); }
public ActionResult Index() { try { var obterCustomns = Mapper.Map <List <GDC_Perfomances>, List <Performance> >(_perfoRepository.ObterTodos().ToList()); var custom = new ListarCustomsViewModel(); List <ListarCustomsViewModel> customViewModel = new List <ListarCustomsViewModel>(); foreach (var itemCustom in obterCustomns) { custom = new ListarCustomsViewModel(); custom.Cliente = Mapper.Map <Cliente>(_clienteRepository.ObterPorId(itemCustom.IdCliente)); custom.Roda = Mapper.Map <Roda>(_rodaRepository.ObterPorId(itemCustom.IdRoda)); custom.Banco = Mapper.Map <Banco>(_bancoRepository.ObterPorId(itemCustom.IdBanco)); custom.Cor_Veiculo = Mapper.Map <Cor_Veiculo>(_corVeiculoRepository.ObterPorId(itemCustom.IdCorVeiculo)); customViewModel.Add(custom); } return(View(customViewModel)); } catch { return(RedirectToAction("Error", "Base")); } }