public async Task <IActionResult> Edit(string id, [Bind("name,amount,Session")] DrugInfoPerStudent drugInfoPerStudent) { if (id != drugInfoPerStudent.name) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(drugInfoPerStudent); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DrugInfoPerStudentExists(drugInfoPerStudent.name)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(drugInfoPerStudent)); }
public async Task <IActionResult> Create([Bind("name,amount,Session")] DrugInfoPerStudent drugInfoPerStudent) { if (ModelState.IsValid) { _context.Add(drugInfoPerStudent); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(drugInfoPerStudent)); }