public ActionResult Add(PensumRegisterModel modelPensum)
        {
            if (_pensumRepository.Filter(x => x.Grade.Id == modelPensum.Grade && x.Name.Equals(modelPensum.Name)).Any())
            {
                _viewMessageLogic.SetNewMessage("Error", "Ya existe un pensum con ese nombre.", ViewMessageType.ErrorMessage);
                return(RedirectToAction("Index", new { gradeId = modelPensum.Grade }));
            }
            var myPensum = Mapper.Map <Pensum>(modelPensum);

            myPensum = _pensumRepository.Create(myPensum);
            const string title   = "Pensum Agregado";
            string       content = "El pensum " + myPensum.Name + " ha sido agregado exitosamente.";

            _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.SuccessMessage);
            return(RedirectToAction("Index", new { gradeId = modelPensum.Grade }));
        }
Example #2
0
        public ActionResult Add(PensumRegisterModel modelPensum)
        {
            var myPensum = new Pensum
            {
                Grade  = _gradeRepository.GetById(modelPensum.IdGrade),
                Course = _courseRepository.GetById(modelPensum.IdCourse)
            };
            Pensum       user    = _pensumRepository.Create(myPensum);
            const string title   = "Pensum Agregado";
            string       content = "El pensum " + user.Id + " ha sido agregado exitosamente.";

            TempData["MessageInfo"] = new MessageModel
            {
                Type    = "SUCCESS",
                Title   = title,
                Content = content
            };
            return(RedirectToAction("Index"));
        }
Example #3
0
        private void DebuggingSeeder(MhotivoContext context)
        {
            var passwordsList = new List <string>
            {
                "arbol",
                "madera",
                "republica",
                "imperio",
                "crucio",
                "excursion",
                "pitonisa",
                "ventilador",
                "oraculo",
                "sanguineo"
            };

            _passwordGenerationService.AddPasswordsToTable(passwordsList);
            _areaRepository.Create(new EducationLevel {
                Name = "Prescolar"
            });
            _areaRepository.Create(new EducationLevel {
                Name = "Primaria"
            });
            _areaRepository.Create(new EducationLevel {
                Name = "Secundaria"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(1).Name, Name = "Kinder"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(1).Name, Name = "Preparatoria"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(2).Name, Name = "Primero"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(2).Name, Name = "Segundo"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(2).Name, Name = "Tercero"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(2).Name, Name = "Cuarto"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(2).Name, Name = "Quinto"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(2).Name, Name = "Sexto"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(3).Name, Name = "Septimo"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(3).Name, Name = "Octavo"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(3).Name, Name = "Noveno"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(3).Name, Name = "Decimo"
            });
            _gradeRepository.Create(new Grade {
                EducationLevel = _areaRepository.GetById(3).Name, Name = "Onceavo"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(1), Name = "English"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(1), Name = "Math"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(2), Name = "English"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(2), Name = "Math"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(2), Name = "Science"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(2), Name = "Espaniol"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(2), Name = "Estudios Sociales"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(3), Name = "Algebra"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(3), Name = "Geometry"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(3), Name = "Physics"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(3), Name = "Biology"
            });
            _courseRepository.Create(new Course {
                Area = _areaRepository.GetById(3), Name = "Physical Education"
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(1), Grade = _gradeRepository.GetById(1)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(1), Grade = _gradeRepository.GetById(2)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(2), Grade = _gradeRepository.GetById(2)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(2), Grade = _gradeRepository.GetById(1)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(3), Grade = _gradeRepository.GetById(3)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(3), Grade = _gradeRepository.GetById(4)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(4), Grade = _gradeRepository.GetById(5)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(5), Grade = _gradeRepository.GetById(6)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(6), Grade = _gradeRepository.GetById(7)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(7), Grade = _gradeRepository.GetById(8)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(8), Grade = _gradeRepository.GetById(9)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(12), Grade = _gradeRepository.GetById(10)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(9), Grade = _gradeRepository.GetById(11)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(10), Grade = _gradeRepository.GetById(12)
            });
            _pensumRepository.Create(new Pensum {
                Course = _courseRepository.GetById(11), Grade = _gradeRepository.GetById(13)
            });
            for (int i = 1; i <= 13; i++)
            {
                _academicYearRepository.Create(new AcademicYear {
                    Approved = true, Grade = _gradeRepository.GetById(i), IsActive = true, Section = "A", Year = 2015
                });
                _academicYearRepository.Create(new AcademicYear {
                    Approved = true, Grade = _gradeRepository.GetById(i), IsActive = true, Section = "B", Year = 2015
                });
                _academicYearRepository.Create(new AcademicYear {
                    Approved = true, Grade = _gradeRepository.GetById(i), IsActive = true, Section = "C", Year = 2015
                });
            }
            var genericTeacher = new User
            {
                DisplayName = "Maestro Generico",
                Email       = "*****@*****.**",
                Password    = "******",
                IsActive    = true,
                Role        = Roles.Maestro
            };

            genericTeacher.EncryptPassword();
            var genericParent = new User
            {
                DisplayName = "Padre Generico",
                Email       = "*****@*****.**",
                Password    = "******",
                IsActive    = true,
                Role        = Roles.Padre
            };

            genericParent.EncryptPassword();
            context.Users.AddOrUpdate(genericTeacher);
            context.Users.AddOrUpdate(genericParent);
            context.SaveChanges();
            var maestroDefault = context.Teachers.FirstOrDefault(x => x.FullName == "Maestro Generico");

            if (maestroDefault == null)
            {
                context.Teachers.AddOrUpdate(new Teacher {
                    IdNumber = "0000000000000", FirstName = "Maestro", LastName = "Generico", FullName = "Maestro Generico", Disable = false, MyGender = Gender.Masculino, MyUser = genericTeacher
                });
            }
            var padreDefault = context.Parents.FirstOrDefault(x => x.FullName == "Padre Generico");

            if (padreDefault == null)
            {
                context.Parents.AddOrUpdate(new Parent {
                    IdNumber = "1234567890", FirstName = "Padre", LastName = "Generico", FullName = "Padre Generico", Disable = false, MyGender = Gender.Femenino, MyUser = genericParent
                });
            }
            context.SaveChanges();
        }