public async Task <ActionResult> Create() { try { // These tasks run in parallel until they are awaited by Task.WhenAll method var alumnosTask = _usuarioEndpoint.GetAll(_userSession.BearerToken); var horariosConsultaFechadosTask = _horarioConsultaFechadoEndpoint.GetAll(_userSession.BearerToken); await Task.WhenAll(alumnosTask, horariosConsultaFechadosTask); var alumnos = _mapper.Map <IEnumerable <MvcUsuarioModel> >(source: alumnosTask.Result); var horarioConsultaFechados = _mapper.Map <IEnumerable <MvcHorarioConsultaFechadoModel> >(source: horariosConsultaFechadosTask.Result); var viewModel = new CreateInscripcionViewModel(horariosConsultaFechados: horarioConsultaFechados, alumnos: alumnos); return(PartialView("_Create", viewModel)); } catch (UnauthorizedRequestException) { return(RedirectToAction("AccessDeniedPartial", "Error")); } catch (Exception ex) { return(RedirectToAction("SpecificErrorPartial", "Error", new { error = ex.Message })); } }
// Index - GET HorarioConsultaFechado public async Task <ActionResult> Index() { try { IEnumerable <HorarioConsultaFechado> entities = await _horarioConsultaFechadoEndpoint.GetAll(_userSession.BearerToken); var horariosConsultaFechados = _mapper.Map <IEnumerable <MvcHorarioConsultaFechadoModel> >(entities); return(View(horariosConsultaFechados)); } catch (UnauthorizedRequestException) { return(RedirectToAction("AccessDenied", "Error")); } catch (Exception ex) { return(RedirectToAction("SpecificError", "Error", new { error = ex.Message })); } }