public ActionResult Create(Student student)
        {
            if (ModelState.IsValid)
            {
                db.Students.Add(student);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(student);
        }
 public ActionResult Edit(Student student)
 {
     if (ModelState.IsValid)
     {
         db.Entry(student).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(student);
 }
Exemple #3
0
 public Student Add(Student student)
 { 
      student.Id = _studentList.Max(s => s.Id) + 1 ;
     _studentList.Add(student);
     return student;
 }
 public Student Add(Student student)
 {
     context.Students.Add(student);
     context.SaveChanges();
     return(student);
 }