Esempio n. 1
0
        public IActionResult GuardarTeacherEducation(TeacherEducationModel model)
        {
            var data = CopyPropierties.Convert <TeacherEducationModel, TeacherEducation>(model);

            if (ModelState.IsValid)
            {
                try
                {
                    _teacherEducation.Save(data);
                }
                catch (Exception e) {
                    return(RedirectToAction("TeacherEducation", new { id = model.TeacherId }));
                }
            }
            else
            {
                var errors = ModelState.Select(x => x.Value.Errors).FirstOrDefault(x => x.Count > 0).First();



                EnviarMensaje.Enviar(TempData, "red", errors.ErrorMessage);

                return(RedirectToAction("TeacherEducation", new { id = model.TeacherId }));
            }

            return(RedirectToAction("TeacherEducation", new { id = model.TeacherId }));
        }
Esempio n. 2
0
        public IActionResult TeacherEducation(int id)
        {
            var model       = new TeacherEducationModel();
            var teacherById = _teacher.GetById(id);

            model.TeacherFullName = teacherById.Contact.ContactName + " " + teacherById.Contact.ContactLastname;

            model.TeacherId            = id;
            model.TeacherEducationList = _teacherEducation.GetAll.Where(x => x.TeacherId == id).ToList();
            ViewBag.EducationType      = new SelectList(_educationType.GetAll, "EducationTypeId", "EducationTypeName");
            return(View(model));
        }