public ActionResult Create([Bind(Include = "ID,FirstName,LastName,Email,DOB,Password,RePassword")] Students students) { if (ModelState.IsValid) { db.Students.Add(students); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(students)); }
public static void Initialize(StudDbContext context) { if (!context.Students.Any()) { context.Students.AddRange( new Student { FirstName = "iPhone X", LastNAme = "Apple", MiddleName = "leon", Sex = "муж", CallName = "dfgdfg" }, new Student { FirstName = "iPhone X", LastNAme = "Apple", MiddleName = "leon", Sex = "жен", CallName = "dfgdfg" } ); context.SaveChanges(); } }
public IActionResult AddStudent(Student student) { try { db.Students.Add(student); db.SaveChanges(); return(Redirect("~/Home/Index")); } catch { return(View()); } }