public async Task <IActionResult> Create([Bind("ID,Name,Surname,Dni,BirthDate,Address,Phone,Email")] Teacher teacher) { if (ModelState.IsValid) { teacher.ID = Guid.NewGuid(); _context.Add(teacher); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(teacher)); }
public async Task <IActionResult> Create([Bind("ID,Subject,TeacherID")] Course course) { if (ModelState.IsValid) { course.ID = Guid.NewGuid(); _context.Add(course); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["TeacherID"] = new SelectList(_context.Teachers, "ID", "ID", course.TeacherID); return(View(course)); }
public void Add(T entity) { Context.Add(entity); Save(); }