Beispiel #1
0
        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));
        }
Beispiel #2
0
        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();
 }