예제 #1
0
 public async Task <IActionResult> Create(int StudentID, DateTime AbsenceDate)
 {
     if (ModelState.IsValid)
     {
         _context.Add(new AbsenceRecord {
             AbsenceDate = AbsenceDate, StudentID = StudentID
         });
         await _context.SaveChangesAsync();
     }
     return(Redirect(Request.Headers["Referer"].ToString()));
 }
예제 #2
0
        public async Task <IActionResult> Create([Bind("ID,Name")] Student student)
        {
            if (ModelState.IsValid)
            {
                _context.Add(student);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(student));
        }