public bool IsHoursOk(Teacher teacher)
        {
            int         hours = GetTotalHours(teacher.IdTeacher);
            TeacherKind kind  = GetKind(teacher.IdTeacherKind);

            return(hours >= kind.MinHours && hours <= kind.MaxHours);
        }
        public IActionResult OnPost()
        {
            TeacherKind teacherKind = new TeacherKind();

            foreach (var someType in db.TeacherKinds)
            {
                if (someType.Name == TeacherKind)
                {
                    teacherKind = someType;
                }
            }

            if (ModelState.IsValid)
            {
                //Fill Helper
                helper.FirstName     = FirstName;
                helper.SecondName    = SecondName;
                helper.FirstSurname  = FirstSurname;
                helper.SecondSurname = SecondSurname;
                helper.Gender        = Gender;
                helper.State         = State;
                helper.DateOfBirth   = DateOfBirth;

                //Build Teacher with helper
                Teacher newTeacher = new Teacher();
                newTeacher.IdTeacherKind = teacherKind.IdTeacherKind;
                newTeacher.FirstName     = FirstName;
                newTeacher.SecondName    = SecondName;
                newTeacher.FirstSurname  = FirstSurname;
                newTeacher.SecondSurname = SecondSurname;
                newTeacher.DateOfBirth   = DateOfBirth;
                newTeacher.Rfc           = helper.CreateRFC();
                newTeacher.Curp          = helper.CreateCURP();
                newTeacher.PayrollNumber = helper.CreatePaycheckNumber();
                newTeacher.Password      = helper.CreatePassword();

                db.Teachers.Add(newTeacher);
                db.SaveChanges();

                HasError = true;
                return(RedirectToPage("../search/teachers"));
            }

            HasError = true;
            return(RedirectToPage("add_teacher", new { HasError }));
        }