//null or manager
 public static tblClinicManager isManager(tblUser e)
 {
     try
     {
         using (MedicalInstitutionEntities4 context = new MedicalInstitutionEntities4())
         {
             tblClinicManager result = (from x in context.tblClinicManagers 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 DeleteManager(tblClinicManager manager)
 {
     try
     {
         using (MedicalInstitutionEntities4 context = new MedicalInstitutionEntities4())
         {
             tblClinicManager toDelete = (from u in context.tblClinicManagers where u.managerId == manager.managerId select u).First();
             context.tblClinicManagers.Remove(toDelete);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
     }
 }
 public static tblClinicManager AddManager(tblClinicManager manager)
 {
     try
     {
         using (MedicalInstitutionEntities4 context = new MedicalInstitutionEntities4())
         {
             if (manager.managerId == 0)
             {
                 //add
                 tblClinicManager newManager = new tblClinicManager();
                 newManager.floorNumber        = manager.floorNumber;
                 newManager.maxNumberOfDoctors = manager.maxNumberOfDoctors;
                 newManager.minNumberOfRooms   = manager.minNumberOfRooms;
                 newManager.numberOfOmissions  = manager.numberOfOmissions;
                 newManager.userId             = manager.userId;
                 context.tblClinicManagers.Add(newManager);
                 context.SaveChanges();
                 manager.managerId = newManager.managerId;
                 return(manager);
             }
             else
             {
                 tblClinicManager managerToEdit = (from x in context.tblClinicManagers where x.managerId == manager.managerId select x).FirstOrDefault();
                 managerToEdit.floorNumber        = manager.floorNumber;
                 managerToEdit.maxNumberOfDoctors = manager.maxNumberOfDoctors;
                 managerToEdit.minNumberOfRooms   = manager.minNumberOfRooms;
                 managerToEdit.numberOfOmissions  = manager.numberOfOmissions;
                 managerToEdit.userId             = manager.userId;
                 context.SaveChanges();
                 return(manager);
             }
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception: " + ex.Message.ToString());
         return(null);
     }
 }