Example #1
0
 public void SharePhysician()
 {
     this.b2ResourceOffer.WaitOne();
     lock (patientLock)
     {
         if (acceptedPatient > 0)
         {
             Console.WriteLine(this.Name + " : Oops... who cannot share a physician when you have patient in the service");
             return;
         }
     }
     lock (physicianLock)
     {
         if (physicianNb <= 0)
         {
             Console.WriteLine(this.Name + " : Oops... you have no available physician for now, maybe you should call the provider");
             return;
         }
         Physicians.WaitOne();
         this.provider.ReceivePhysician();
         this.physicianNb--;
         Console.WriteLine(this.Name + " : \nTotal number of physician: " + this.physicianNb);
     }
     this.b2ResourceOffer.ReleaseMutex();
 }
Example #2
0
 public virtual List <PhysicianBase> ActivePhysicians()
 {
     try
     {
         return(Physicians.Instance().Where(p => p.IsActive == true).ToList());
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Example #3
0
 public virtual PhysicianBase GetPhysician(int id)
 {
     try
     {
         return(Physicians.Instance().Where(p => p.ID == id).FirstOrDefault());
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Example #4
0
 public virtual Physicians GetPhysicians()
 {
     try
     {
         return(Physicians.Instance());
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Example #5
0
 public virtual HttpResponseMessage AddPhysician(PhysicianBase physician)
 {
     try
     {
         Physicians.Instance().Add(physician);
         return(Request.CreateResponse(HttpStatusCode.Created, new Message()
         {
             Content = string.Format("New Physician is added successfully")
         }));
     }
     catch (Exception exception)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError,
                                       new Message()
         {
             Content = exception.Message
         }));
     }
 }
Example #6
0
 public virtual HttpResponseMessage RemovePhysician(int id)
 {
     try
     {
         PhysicianBase physician = Physicians.Instance().Where(p => p.ID == id).FirstOrDefault();
         bool          isRemoved = Physicians.Instance().Remove(physician);
         return(isRemoved ? Request.CreateResponse(HttpStatusCode.OK, new Message()
         {
             Content = string.Format("Physician with an ID {0} is removed!", id)
         }) :
                Request.CreateResponse(HttpStatusCode.BadRequest, new Message()
         {
             Content = string.Format("Unable to remove Physician using {0} ID", id)
         }));
     }
     catch (Exception exception)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError,
                                       new Message()
         {
             Content = exception.Message
         }));
     }
 }