//creating an instance of findDoctor table (Model) as a parameter
 public bool commitInsert(findDoctor doctor)
 {
     //to ensure all data will be disposed of when finished
     using (objDoctor)
     {
         //using our model to set table columns to new values being passed and providing it to the insert command
         objDoctor.findDoctors.InsertOnSubmit(doctor);
         //commit insert with db
         objDoctor.SubmitChanges();
         return(true);
     }
 }
Esempio n. 2
0
 public ActionResult doctorDelete(int Id, findDoctor doctor)
 {
     //Selected value will be deleted from the database
     try
     {
         objDoctor.commitDelete(Id);
         return(RedirectToAction("doctorIndex"));
     }
     catch
     {
         return(View());
     }
 }
Esempio n. 3
0
 public ActionResult doctorUpdate(int Id, findDoctor doctor)
 {
     //If all the input were valid , then database will be updated
     if (ModelState.IsValid)
     {
         try
         {
             objDoctor.commitUpdate(Id, doctor.fname, doctor.lname, doctor.speciality, doctor.branch_id, doctor.gender);
             return(RedirectToAction("doctorIndex"));
         }
         catch
         {
             return(View());
         }
     }
     return(View());
 }
Esempio n. 4
0
 public ActionResult doctorInsert(findDoctor doctor)
 {
     if (ModelState.IsValid)
     {
         try
         {
             objDoctor.commitInsert(doctor);
             return(RedirectToAction("doctorIndex")); //On sucessful insert, redirect to the index view
         }
         catch
         {
             //Error handling, return to  view if something goes wrong
             return(View());
         }
     }
     return(View());
 }