public IActionResult Editar(int id) { var data = _teacher.GetById(id); var teacherEducation = new TeacherEducation(); var model = CopyPropierties.Convert <Teacher, TeacherModel>(data); model.HigherTeacherEducation = teacherEducation; model.Name = data.Contact.ContactName; model.LastName = data.Contact.ContactLastname; model.Document = data.Contact.ContactDocumentNumber; model.Nacionality = data.Contact.Nationality; ViewBag.ContactTypes = new SelectList(_contactType.GetAll, "ContactTypeId", "ContactTypeName"); ViewBag.DocumentType = new SelectList(_documentType.GetAll, "DocumentTypeId", "DocumentTypeName"); ViewBag.Countries = new SelectList(_country.GetAll, "CountryId", "CountryName"); ViewBag.Cities = new SelectList(_city.Cities, "CityId", "CityName"); ViewBag.AddressTypes = new SelectList(_addressType.addressTypes, "AddressTypeId", "AddressTypeName"); ViewBag.TeacherHiringType = new SelectList(_teacherHiringType.GetAll, "TeacherHiringTypeId", "TeacherHiringTypeName"); ViewBag.EducationType = new SelectList(_educationType.GetAll, "EducationTypeId", "EducationTypeName"); ViewBag.TeacherEducation = new SelectList(_teacherEducation.GetAll, "TeacherEducationId", "TeacherEducationTitle"); ViewBag.Nationality = new SelectList(_nationality.GetAll, "NationalityId", "NationalityName"); ViewBag.MatirialStatus = new SelectList(_matirialStatus.GetAll, "MaritalStatusId", "MaritalStatusName"); ViewBag.University = new SelectList(_university.Universities, "UniversityId", "UniversityName"); return(View("Crear", model)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,UniversityName,Speciality,Duration,TeacherId")] TeacherEducation teacherEducation) { if (id != teacherEducation.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(teacherEducation); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TeacherEducationExists(teacherEducation.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["TeacherId"] = new SelectList(_context.Teachers, "Id", "Surname", teacherEducation.TeacherId); return(View(teacherEducation)); }
public async Task <IActionResult> Create([Bind("Id,UniversityName,Speciality,Duration,TeacherId")] TeacherEducation teacherEducation) { if (ModelState.IsValid) { _context.Add(teacherEducation); var teacher = _context.Teachers.Find(teacherEducation.TeacherId); teacher.Is_Filled_Education = true; _context.Update(teacher); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["TeacherId"] = new SelectList(_context.Teachers, "Id", "Surname", teacherEducation.TeacherId); return(View(teacherEducation)); }
public void Save(TeacherEducation model) { var now = DateTime.Now; if (model.TeacherEducationId != 0) { model.UpgradeDate = now; _context.TeacherEducation.Update(model); } else { model.CreationDate = now; model.StatusId = StatusValues.Activo; _context.Add(model); } _context.SaveChanges(); }