Exemplo n.º 1
0
        public ActionResult Add(GradeRegisterModel modelGrade)
        {
            string title;
            string content;
            var    gradeModel = Mapper.Map <GradeRegisterModel, Grade>(modelGrade);
            var    myGrade    = _gradeRepository.GenerateGradeFromRegisterModel(gradeModel);
            var    existGrade =
                _gradeRepository.GetAllGrade()
                .FirstOrDefault(
                    g => g.Name.Equals(modelGrade.Name) && g.EducationLevel.Equals(modelGrade.EducationLevel));

            if (existGrade != null)
            {
                title   = "Grado";
                content = "El grado " + existGrade.Name + " ya existe.";
                _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.InformationMessage);
                return(RedirectToAction("Index"));
            }
            var grade = _gradeRepository.Create(myGrade);

            title   = "Grado Agregado";
            content = grade.Name + " grado ha sido guardado exitosamente.";
            _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.SuccessMessage);
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public ActionResult Add(GradeRegisterModel modelGrade)
        {
            string title;
            string content;
            var    gradeModel = Mapper.Map <GradeRegisterModel, Grade>(modelGrade);
            var    query      =
                _gradeRepository.Filter(
                    g => g.Name.Equals(gradeModel.Name) && g.EducationLevel.Id == gradeModel.EducationLevel.Id);

            if (query.Any())
            {
                title   = "Error!";
                content = "El Grado ya existe.";
                _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.ErrorMessage);
                return(RedirectToAction("Index"));
            }
            var grade = _gradeRepository.Create(gradeModel);

            title   = "Grado Agregado";
            content = grade.Name + " grado ha sido guardado exitosamente.";
            _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.SuccessMessage);
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        public IActionResult CreateGrade(string id)
        {
            if (string.IsNullOrEmpty(id) == false)
            {
                GradeManager gradeManager = new GradeManager();
                Grade        grade        = new Grade();

                bool result = gradeManager.isValid(id, ref grade);

                if (result == true && gradeRepository.Create(grade) == true)
                {
                    gradeRepository.Save();
                    return(new JsonResult(new
                    {
                        iserror = false,
                        message = "",
                        Grade = grade
                    }));
                }
                else
                {
                    return(new JsonResult(new
                    {
                        iserror = true,
                        message = "Вы ввели не верное название класса или данный класс уже существует.",
                        Grade = ""
                    }));
                }
            }
            return(new JsonResult(new
            {
                iserror = true,
                message = "Введите значение",
                Grade = ""
            }));
        }
Exemplo n.º 4
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();
        }