Beispiel #1
0
        public ActionResult CrearVersionRubrica(CrearVersionRubricaViewModel Model)
        {
            var ValidationLogic = new ValidationLogic(ModelState);

            Model.Rubrica.FechaCreacion = DateTime.Now;
            Model.Rubrica.EsActual = true;

            ValidationLogic.Valid(Model.Rubrica.Descripcion, "Rubrica.Descripcion", ValidationOption.IsNotEmpty);
            ValidationLogic.Valid(Model.Rubrica.RubricaId, "Rubrica.RubricaId", ValidationOption.IsNotEmpty);
            ValidationLogic.Valid(Model.Rubrica.TipoArtefacto, "Rubrica.TipoArtefacto", ValidationOption.IsNotEmpty);
            ValidationLogic.Valid(Model.Rubrica.TipoRubrica, "Rubrica.TipoRubrica", ValidationOption.IsNotEmpty);
            ValidationLogic.Valid(Model.Rubrica.Version, "Rubrica.Version", ValidationOption.IsNotEmpty);
            ValidationLogic.Valid(Model.Rubrica.CreadorId, "Rubrica.CreadorId", ValidationOption.IsNotEmpty);

            if (RubricOnRepositoryFactory.GetVersionesRubricasRepository().GetOne(Model.Rubrica.RubricaId, Model.Rubrica.TipoArtefacto, Model.Rubrica.Version) != null)
            {
                ModelState.AddModelError("Rubrica.Version", "");
            }

            if (!ModelState.IsValid)
            {
                PostMessage("Revise los datos ingresados.", MessageType.Error);
                return View(Model);
            }

            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    var Actuales = RubricOnRepositoryFactory.GetVersionesRubricasRepository().GetWhere(x => x.RubricaId == Model.Rubrica.RubricaId && x.TipoArtefacto == Model.Rubrica.TipoArtefacto && x.EsActual == true);
                    foreach (var actual in Actuales)
                        actual.EsActual = false;

                    RubricOnRepositoryFactory.GetVersionesRubricasRepository().Update(Actuales);
                    RubricOnRepositoryFactory.SubmitChanges(true);

                    var Rubrica = new RubricasBE() { RubricaId = Model.Rubrica.RubricaId, TipoArtefacto = Model.Rubrica.TipoArtefacto };

                    RubricOnRepositoryFactory.GetRubricasRepository().InsertOrUpdate(Rubrica);
                    RubricOnRepositoryFactory.SubmitChanges(true);

                    RubricOnRepositoryFactory.GetVersionesRubricasRepository().InsertOrUpdate(Model.Rubrica);
                    RubricOnRepositoryFactory.SubmitChanges(true);

                    scope.Complete();

                    PostMessage("La version ha sido creada exitosamente.", MessageType.Success);
                }
            }
            catch (Exception ex)
            {
                PostMessage("Ha ocurrido un error.", MessageType.Error);
            }

            return RedirectToAction("ListarVersionesRubrica", new { RubricaId = Model.Rubrica.RubricaId, TipoArtefacto = Model.Rubrica.TipoArtefacto });
        }
Beispiel #2
0
        public ActionResult InicioEvaluacionRubrica(RubricasBE Rubrica, String CodigoEvaluadoId, String CodigoEvaluadorId, FormCollection formCollection)
        {
            var ValidationLogic = new ValidationLogic(ModelState);

            ValidationLogic.Valid(Rubrica.RubricaId, "Rubrica.RubricaId", ValidationOption.IsNotEmpty);
            ValidationLogic.Valid(Rubrica.TipoArtefacto, "Rubrica.TipoArtefacto", ValidationOption.IsNotEmpty);
            ValidationLogic.Valid(CodigoEvaluadoId, "CodigoEvaluadoId", ValidationOption.IsNotEmpty);
            ValidationLogic.Valid(CodigoEvaluadorId, "CodigoEvaluadorId", ValidationOption.IsNotEmpty);

            if (!ModelState.IsValid)
            {
                PostMessage("Revise los datos ingresados.", MessageType.Error);
                return View(Rubrica);
            }

            return RedirectToAction("EvaluarRubrica", new { RubricaId = Rubrica.RubricaId, TipoArtefacto = Rubrica.TipoArtefacto, CodigoEvaluadoId = CodigoEvaluadoId, CodigoEvaluadorId = CodigoEvaluadorId });
        }