public ActionResult Edit(Student student) { try { StudentGateway studentGateway=new StudentGateway(); studentGateway.Update(student); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Create(Student student) { try { StudentGateway studentGateway=new StudentGateway(); studentGateway.Insert(student); return RedirectToAction("Index"); } catch { return View(); } }
public void Insert(Student aStudent) { CommandObj.CommandText = "spAddStudent"; CommandObj.CommandType = CommandType.StoredProcedure; CommandObj.Parameters.Clear(); CommandObj.Parameters.AddWithValue("@Name", aStudent.Name); CommandObj.Parameters.AddWithValue("@RegNo", aStudent.RegNo); CommandObj.Parameters.AddWithValue("@Address", aStudent.Address); CommandObj.Parameters.AddWithValue("@Phone", aStudent.Phone); CommandObj.Parameters.AddWithValue("@Email", aStudent.Email); ConnectionObj.Open(); CommandObj.ExecuteNonQuery(); CommandObj.Dispose(); ConnectionObj.Close(); }
public ActionResult Delete(Student student) { try { StudentGateway studentGateway=new StudentGateway(); studentGateway.Delete(student.Id); return RedirectToAction("Index"); } catch { return View(); } }