public IActionResult Create([Bind("Id,Name,Credits")] Subject subject)
 {
     if (ModelState.IsValid)
     {
         _context.Add(subject);
         _context.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(subject));
 }
Beispiel #2
0
 public IActionResult Create([Bind("Id,Name,ContactNumber")] Teacher teacher)
 {
     if (ModelState.IsValid)
     {
         _context.Add(teacher);
         _context.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(teacher));
 }
 public IActionResult Create([Bind("Id,SubjectId,TeacherId,StarTime,EndTime,Day")] TimeTable timeTable)
 {
     if (ModelState.IsValid)
     {
         _context.Add(timeTable);
         _context.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     ViewData["SubjectId"] = new SelectList(_context.Subject, "Id", "Name", timeTable.SubjectId);
     ViewData["TeacherId"] = new SelectList(_context.Teacher, "Id", "ContactNumber", timeTable.TeacherId);
     return(View(timeTable));
 }