//creating an instance of findDoctor table (Model) as a parameter public bool commitInsert(contact_list contact) { using (objContact) { //using our model to set table columns to new values being passed and providing it to the insert command objContact.contact_lists.InsertOnSubmit(contact); //commit insert with db objContact.SubmitChanges(); return(true); } }
public ActionResult ContactDelete(int Id, contact_list contact) { //Selected value will be deleted from the database try { objContact.commitDelete(Id); return(RedirectToAction("ContactIndex")); } catch { return(View()); } }
public ActionResult ContactUpdate(int Id, contact_list contact) { //If all the input were valid , then database will be updated if (ModelState.IsValid) { try { objContact.commitUpdate(Id, contact.department, contact.detail, contact.location, contact.phone, contact.fax, contact.head); return(RedirectToAction("ContactIndex")); } catch { return(View()); } } return(View()); }
public ActionResult ContactInsert(contact_list contact) { if (ModelState.IsValid) { try { objContact.commitInsert(contact); return(RedirectToAction("ContactIndex")); //On sucessful insert, redirect to the index view } catch { //Error handling, return to view if something goes wrong return(View()); } } return(View()); }