// Index Nueva Inscripción (By Current Alumno User) public async Task <ActionResult> NuevaConsulta() { try { var departamentosTask = _departamentoEndpoint.GetAll(_userSession.BearerToken); var materiasTask = _materiaEndpoint.GetAll(_userSession.BearerToken); var profesoresTask = _usuarioEndpoint.GetAllProfesores(_userSession.BearerToken); await Task.WhenAll(departamentosTask, materiasTask, profesoresTask); var departamentos = _mapper.Map <IEnumerable <MvcDepartamentoModel> >(source: departamentosTask.Result); var materias = _mapper.Map <IEnumerable <MvcMateriaModel> >(source: materiasTask.Result); var profesores = _mapper.Map <IEnumerable <MvcUsuarioModel> >(source: profesoresTask.Result); var viewModel = new ShowHorariosParaInscribirViewModel( departamentos: departamentos, materias: materias, profesores: profesores); return(View(viewModel)); } catch (UnauthorizedRequestException) { return(RedirectToAction("AccessDenied", "Error")); } catch (Exception ex) { return(RedirectToAction("SpecificError", "Error", new { error = ex.Message })); } }
public async Task <ActionResult> Create() { try { // These tasks run in parallel until they are awaited by Task.WhenAll method var profesoresTask = _usuarioEndpoint.GetAll(_userSession.BearerToken); var materiasTask = _materiaEndpoint.GetAll(_userSession.BearerToken); await Task.WhenAll(profesoresTask, materiasTask); var profesores = _mapper.Map <IEnumerable <MvcUsuarioModel> >(source: profesoresTask.Result); var materias = _mapper.Map <IEnumerable <MvcMateriaModel> >(source: materiasTask.Result); var viewModel = new CreateHorarioConsultaViewModel(materias: materias, profesores: profesores); return(PartialView("_Create", viewModel)); } catch (UnauthorizedRequestException) { return(RedirectToAction("AccessDeniedPartial", "Error")); } catch (Exception ex) { return(RedirectToAction("SpecificErrorPartial", "Error", new { error = ex.Message })); } }
public async Task <ActionResult> CreateHorario() { try { IEnumerable <Materia> entities = await _materiaEndpoint.GetAll(_userSession.BearerToken); var materias = _mapper.Map <IEnumerable <MvcMateriaModel> >(source: entities); var viewModel = new CreateOwnHorarioConsultaViewModel(materias: materias); return(PartialView("_CreateOwnHorario", viewModel)); } catch (UnauthorizedRequestException) { return(RedirectToAction("AccessDenied", "Error")); } catch (Exception ex) { return(RedirectToAction("SpecificError", "Error", new { error = ex.Message })); } }
public async Task LoadMaterias() { try { IEnumerable <Materia> entities = await _materiaEndpoint.GetAll(_usuarioLogged.Token); MateriasInForm = _mapper.Map <BindingList <WpfMateriaModel> >(entities); } catch (UnauthorizedRequestException) { _events.PublishOnUIThread(new NotAuthorizedEvent()); } catch (Exception ex) { ErrorMessages = new BindingList <string> { $"{ex.Message} Ha ocurrido un error. Por favor contacte a soporte" }; } }
// Index - GET Materia public async Task <ActionResult> Index() { try { IEnumerable <Materia> entities = await _materiaEndpoint.GetAll(_userSession.BearerToken); var materias = _mapper.Map <IEnumerable <MvcMateriaModel> >(entities); var viewModel = new ShowMateriasViewModel(materias: materias); return(View(viewModel)); } catch (UnauthorizedRequestException) { return(RedirectToAction("AccessDenied", "Error")); } catch (Exception ex) { return(RedirectToAction("SpecificError", "Error", new { error = ex.Message })); } }