public ActionResult MostrarGruposCursoEvaluadorGrupos(MostrarGruposCursoEvaluadorGruposViewModel model, FormCollection formCollection) { if (!PermitirAcceso()) return RedirigirFaltaAcceso(); var EvaluacionesGruposProfesor = new List<EvaluacionesGruposProfesorBE>(); foreach (var key in formCollection.Keys) { var keyStr = key.ToString(); if (!keyStr.StartsWith("EVAL_")) continue; var GrupoId = keyStr.Substring("EVAL_".Length); var ProfesorId = formCollection[keyStr]; if (ProfesorId == null || ProfesorId == "") continue; var Profesor = SSIARepositoryFactory.GetProfesoresRepository().GetOne(ProfesorId); if (Profesor == null) { PostMessage("No se encontro al profesor. Revisar los datos.", MessageType.Error); ModelState.AddModelError(keyStr, ""); continue; } var Grupo = ePortafolioRepositoryFactory.GetGruposRepository().GetOne(GrupoId.ToInteger()); if (Grupo == null) { PostMessage("No se encontro el grupo. Revisar los datos.", MessageType.Error); ModelState.AddModelError(keyStr, ""); continue; } EvaluacionesGruposProfesor.Add(new EvaluacionesGruposProfesorBE() { GrupoId = GrupoId.ToInteger(), ProfesorId = ProfesorId }); } if (ModelState.IsValid) { try { var GruposTrabajoId = ePortafolioRepositoryFactory.GetGruposRepository().GetWhere(x => x.TrabajoId == model.TrabajoId).Select(x => x.GrupoId); using (TransactionScope scope = new TransactionScope()) { ePortafolioRepositoryFactory.GetEvaluacionesGruposProfesorRepository().DeleteWhere(x => GruposTrabajoId.Contains(x.GrupoId)); ePortafolioRepositoryFactory.SubmitChanges(true); ePortafolioRepositoryFactory.GetEvaluacionesGruposProfesorRepository().InsertOrUpdate(EvaluacionesGruposProfesor); ePortafolioRepositoryFactory.SubmitChanges(true); scope.Complete(); PostMessage("Los evaluadores han sido asociados exitosamente.", MessageType.Success); } } catch (Exception ex) { PostMessage("Ha ocurrido un error.", MessageType.Error); } } var MostrarGruposCursoEvaluadorGruposViewModel = new MostrarGruposCursoEvaluadorGruposViewModel(model.TrabajoId); MostrarGruposCursoEvaluadorGruposViewModel.EvaluacionesGruposProfesor.Clear(); foreach (var key in formCollection.Keys) { var keyStr = key.ToString(); if (!keyStr.StartsWith("EVAL_")) continue; var GrupoId = keyStr.Substring("EVAL_".Length); var ProfesorId = formCollection[keyStr]; MostrarGruposCursoEvaluadorGruposViewModel.EvaluacionesGruposProfesor.Add(new EvaluacionesGruposProfesorBE() { GrupoId = GrupoId.ToInteger(), ProfesorId = ProfesorId }); } return PartialView(MostrarGruposCursoEvaluadorGruposViewModel); }
public ActionResult MostrarGruposCursoEvaluadorGrupos(int? TrabajoId) { if (!PermitirAcceso()) return RedirigirFaltaAcceso(); if (!TrabajoId.HasValue) { PostMessage("Debe seleccionar un trabajo.", MessageType.Info); return View("Empty"); } var MostrarGruposCursoEvaluadorGruposViewModel = new MostrarGruposCursoEvaluadorGruposViewModel(TrabajoId.Value); return View(MostrarGruposCursoEvaluadorGruposViewModel); }