// Bind(Include = "...") is used to avoid overposting attacks public async Task <ActionResult> EditInscripcion(EditOwnInscripcionViewModel viewModel) { try { Usuario user = await _usuarioEndpoint.GetCurrentUsuario(token : _userSession.BearerToken); viewModel.SetAlumno(user.Id); 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("AccessDeniedPartial", "Error")); } catch (BadRequestException ex) { viewModel.SetEstadosAsSelectList(); ModelState.AddModelErrors(ex.Errors); return(PartialView("_EditOwnInscripcion", viewModel)); } catch (Exception ex) { return(RedirectToAction("SpecificErrorPartial", "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); await Task.WhenAll(inscripcionTask); var inscripcion = _mapper.Map <MvcInscripcionModel>(source: inscripcionTask.Result); var viewModel = new EditOwnInscripcionViewModel(inscripcion: inscripcion); return(PartialView("_EditOwnInscripcion", viewModel)); } catch (UnauthorizedRequestException) { return(RedirectToAction("AccessDeniedPartial", "Error")); } catch (NotFoundRequestException ex) { return(Content($"{ex.StatusCode}: Elemento no encontrado")); } catch (Exception ex) { return(RedirectToAction("SpecificErrorPartial", "Error", new { error = ex.Message })); } } }