public async Task <DataResponse <Narrador> > GetNarrador() { try { return(await _narradorRepository.GetNarradores()); } catch (Exception ex) { File.WriteAllText("log.txt", ex.Message + " - " + ex.StackTrace); throw new Exception("Erro no banco de dados, contate o administrador"); } }
public async Task <IActionResult> Cadastrar() { List <Time> times = await _timeRepository.GetTimes().Result.Data; List <Narrador> narradores = await _narradorRepository.GetNarradores().Result.Data; var configuration = new MapperConfiguration(cfg => { cfg.CreateMap <Time, TimeQueryViewModel>(); cfg.CreateMap <Narrador, NarradorQueryViewModel>(); }); IMapper mapper = configuration.CreateMapper(); List <TimeQueryViewModel> dadosTime = mapper.Map <List <TimeQueryViewModel> >(times); ViewBag.Times = dadosTime; List <NarradorQueryViewModel> dadosNarrador = mapper.Map <List <NarradorQueryViewModel> >(narradores); ViewBag.Narradores = dadosNarrador; return(View()); }