//null or doctor
 public static tblClinicDoctor isDoctor(tblUser e)
 {
     try
     {
         using (MedicalInstitutionEntities4 context = new MedicalInstitutionEntities4())
         {
             tblClinicDoctor result = (from x in context.tblClinicDoctors where x.userId == e.userId select x).FirstOrDefault();
             return(result);
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception " + ex.Message.ToString());
         return(null);
     }
 }
 public static void DeleteDoctor(tblClinicDoctor doctor)
 {
     try
     {
         using (MedicalInstitutionEntities4 context = new MedicalInstitutionEntities4())
         {
             tblClinicDoctor toDelete = (from u in context.tblClinicDoctors where u.doctorId == doctor.doctorId select u).First();
             context.tblClinicDoctors.Remove(toDelete);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
     }
 }
 public static tblClinicDoctor AddDoctor(tblClinicDoctor doctor)
 {
     try
     {
         using (MedicalInstitutionEntities4 context = new MedicalInstitutionEntities4())
         {
             if (doctor.doctorId == 0)
             {
                 //add
                 tblClinicDoctor newDoctor = new tblClinicDoctor();
                 newDoctor.account             = doctor.account;
                 newDoctor.admissionOfPatients = doctor.admissionOfPatients;
                 newDoctor.department          = doctor.department;
                 newDoctor.managerId           = doctor.managerId;
                 newDoctor.shift  = doctor.shift;
                 newDoctor.userId = doctor.userId;
                 context.tblClinicDoctors.Add(newDoctor);
                 context.SaveChanges();
                 doctor.doctorId = newDoctor.doctorId;
                 return(doctor);
             }
             else
             {
                 tblClinicDoctor doctorToEdit = (from x in context.tblClinicDoctors where x.doctorId == doctor.doctorId select x).FirstOrDefault();
                 doctorToEdit.account             = doctor.account;
                 doctorToEdit.admissionOfPatients = doctor.admissionOfPatients;
                 doctorToEdit.department          = doctor.department;
                 doctorToEdit.managerId           = doctor.managerId;
                 doctorToEdit.userId = doctor.userId;
                 doctorToEdit.shift  = doctor.shift;
                 context.SaveChanges();
                 return(doctor);
             }
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception: " + ex.Message.ToString());
         return(null);
     }
 }