public ActionResult OnPost() { if (!ModelState.IsValid) { studentRegistrationForms = _studentformdbcontext.StudentRegistrationForm.ToList(); return(Page()); } _studentformdbcontext.StudentRegistrationForm.Add(StudentRegistrationForm); _studentformdbcontext.SaveChanges(); return(Redirect("/Index")); }
public ActionResult OnPost() { if (!ModelState.IsValid) { return(Page()); } StudentRegistrationForm stud = new StudentRegistrationForm(); stud = _studentFormDBContext.StudentRegistrationForm. FirstOrDefault(student => student.ID == StudentRegistrationForm.ID); if (stud != null) { stud.Idnumber = StudentRegistrationForm.Idnumber; stud.Name = StudentRegistrationForm.Name; stud.Course = StudentRegistrationForm.Course; stud.Year = StudentRegistrationForm.Year; stud.TshirtColor = StudentRegistrationForm.TshirtColor; stud.Size = StudentRegistrationForm.Size; stud.AmountPaid = StudentRegistrationForm.AmountPaid; _studentFormDBContext.Update(stud); _studentFormDBContext.SaveChanges(); } return(Redirect("StudentRecord")); }