// Bind(Include = "...") is used to avoid overposting attacks public async Task <ActionResult> EditInscripcion(EditInscripcionRecibidaViewModel viewModel) { try { var entity = _mapper.Map <Inscripcion>(viewModel.Inscripcion); if (entity.State == null) { entity.State = Inscripcion.InscripcionStates.Active; } await _inscripcionEndpoint.Put(entity, _userSession.BearerToken); } catch (UnauthorizedRequestException) { return(RedirectToAction("AccessDenied", "Error")); } catch (BadRequestException ex) { viewModel.SetEstadosAsSelectList(); ModelState.AddModelErrors(ex.Errors); return(PartialView("_EditInscripcionRecibida", viewModel)); } catch (Exception ex) { return(RedirectToAction("SpecificError", "Error", new { error = ex.Message })); } return(Content("OK")); }
public async Task <ActionResult> EditInscripcion(int?id) { { if (id == null) { return(Content("Debe incluir el id")); } try { var inscripcionTask = _inscripcionEndpoint.Get(id, _userSession.BearerToken); var alumnosTask = _usuarioEndpoint.GetAll(_userSession.BearerToken); await Task.WhenAll(inscripcionTask, alumnosTask); var inscripcion = _mapper.Map <MvcInscripcionModel>(source: inscripcionTask.Result); var alumnos = _mapper.Map <IEnumerable <MvcUsuarioModel> >(source: alumnosTask.Result); var viewModel = new EditInscripcionRecibidaViewModel(inscripcion: inscripcion); return(PartialView("_EditInscripcionRecibida", viewModel)); } catch (UnauthorizedRequestException) { return(RedirectToAction("AccessDenied", "Error")); } catch (NotFoundRequestException ex) { return(Content($"{ex.StatusCode}: Elemento no encontrado")); } catch (Exception ex) { return(RedirectToAction("SpecificError", "Error", new { error = ex.Message })); } } }