public IActionResult OnPost(int studentId)
        {
            var student = studentData.Delete(studentId);

            studentData.Commit();

            if (student == null)
            {
                return(RedirectToPage("./NotFound"));
            }

            TempData["Message"] = $"{student.Name} deleted";
            return(RedirectToPage("./List"));
        }
Esempio n. 2
0
        public IActionResult DeleteStudent(StudentEditModel model)
        {
            if (ModelState.IsValid)
            {
                _studentData.Delete(model.StudentName);

                foreach (var behavior in _behaviorData.GetAll())
                {
                    if (behavior.StudentName == model.StudentName)
                    {
                        _behaviorData.Delete(behavior.BehaviorName, model.StudentName);
                    }
                }

                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(View());
            }
        }
Esempio n. 3
0
 public ActionResult Delete(int id, FormCollection form)
 {
     db.Delete(id);
     return(RedirectToAction("Index"));
 }
 public IActionResult DeletePost(string id)
 {
     _studentData.Delete(id);
     return(RedirectToAction("Students", "Student"));
 }