Exemplo n.º 1
0
 /*get patient views of current logged in patient*/
 public JsonResult getCurrentPatientView(Guid docID)
 {
     try
     {
         Guid   currentPatinetID                = Guid.Empty;
         byte   currentPatientRate              = 0;
         string currentPatientComment           = "";
         bool   isAuthenticated                 = false;
         bool   canPatientMakeRateForThisDoctor = false;
         if (isUserAuthenticated())
         {
             isAuthenticated = true;
             patient     currentPatient = getCurrentpatient();
             patientView currPtView     = currentPatient.patientViews.FirstOrDefault(pv => pv.doctorID == docID);
             if (currPtView != null)
             {
                 currentPatientRate              = currPtView.rate;
                 currentPatientComment           = currPtView.comment;
                 currentPatinetID                = currPtView.patientID;
                 canPatientMakeRateForThisDoctor = currentPatient.reservings.Any(r => r.doctorID == docID && r.done);
             }
         }
         return(Json(new { isAuthenticated = isAuthenticated,
                           currentPtRate = currentPatientRate,
                           currentPtComment = currentPatientComment,
                           ptID = (currentPatinetID == Guid.Empty)?"0":currentPatinetID.ToString(),
                           canRate = canPatientMakeRateForThisDoctor }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception)
     {
         return(Json(false, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 2
0
 /*add comment that written by current logged patient*/
 public JsonResult addPatientComment(Guid doctorID, string comment)
 {
     try
     {
         if (string.IsNullOrWhiteSpace(comment) || string.IsNullOrEmpty(comment))
         {
             return(Json(false, JsonRequestBehavior.AllowGet));
         }
         comment = comment.Trim();
         if (!isUserAuthenticated())
         {
             return(Json(false, JsonRequestBehavior.AllowGet));
         }
         patient currentPatient = getCurrentpatient();
         if (!currentPatient.reservings.Any(r => r.doctorID == doctorID && r.done))
         {
             return(Json(false, JsonRequestBehavior.AllowGet));
         }
         patientView foundedPatientView = currentPatient.patientViews.FirstOrDefault(pv => pv.doctorID == doctorID);
         if (foundedPatientView != null)
         {//make rate updating
             foundedPatientView.comment = comment;
             UpdateFields <patientView>(foundedPatientView, db.Entry(foundedPatientView), pv => pv.comment);
             // db.Entry(foundedPatientView).State = System.Data.Entity.EntityState.Modified;
         }
         else
         {//add new rate
             foundedPatientView           = new patientView();
             foundedPatientView.comment   = comment;
             foundedPatientView.rate      = 0;
             foundedPatientView.doctorID  = doctorID;
             foundedPatientView.patientID = currentPatient.id;
             db.patientViews.Add(foundedPatientView);
         }
         db.SaveChanges();//save update or add
         return(Json(true, JsonRequestBehavior.AllowGet));
     }
     catch (Exception)
     {
         return(Json(false, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 3
0
 /*add rate that marked by current patient*/
 public JsonResult addPatientRate(byte rate, Guid doctorID)
 {
     if (rate > 5 || rate < 0)
     {
         return(Json(false, JsonRequestBehavior.AllowGet));
     }
     try
     {
         if (!isUserAuthenticated())
         {
             return(Json(false, JsonRequestBehavior.AllowGet));
         }
         patient currentPatient = getCurrentpatient();
         if (!currentPatient.reservings.Any(r => r.doctorID == doctorID && r.done))
         {
             return(Json(false, JsonRequestBehavior.AllowGet));
         }
         patientView foundedPatientView = currentPatient.patientViews.FirstOrDefault(pv => pv.doctorID == doctorID);
         if (foundedPatientView != null)
         {//make rate updating
             foundedPatientView.rate = rate;
             UpdateFields <patientView>(foundedPatientView, db.Entry(foundedPatientView), pv => pv.rate);
         }
         else
         {//add new rate
             foundedPatientView           = new patientView();
             foundedPatientView.rate      = rate;
             foundedPatientView.doctorID  = doctorID;
             foundedPatientView.patientID = currentPatient.id;
             db.patientViews.Add(foundedPatientView);
         }
         db.SaveChanges();//save update or add
         return(Json(true, JsonRequestBehavior.AllowGet));
     }
     catch (Exception)
     {
         return(Json(false, JsonRequestBehavior.AllowGet));
     }
 }