/*add comment on advice by javascript*/
 public JsonResult addCommentOnAdvice(Guid adviceID, string comment)
 {
     if (!User.Identity.IsAuthenticated)
     {
         return(Json("notLogged", JsonRequestBehavior.AllowGet));
     }
     try
     {
         Guid            currentPtID = Guid.Parse(Session["patientID"].ToString());
         patient         currentPt   = db.patients.SingleOrDefault(p => p.id == currentPtID);
         commentOnAdvice newcomment  = new commentOnAdvice();
         newcomment.id      = Guid.NewGuid();
         newcomment.comment = comment;
         if (!db.commentOnAdvices.Any(c => c.adviceID == adviceID && c.patientID == currentPtID))
         {
             newcomment.seen = true;
         }
         newcomment.adviceID  = adviceID;
         newcomment.patientID = currentPtID;
         db.commentOnAdvices.Add(newcomment);
         db.SaveChanges();
         return(Json(new { name = currentPt.username }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(false, JsonRequestBehavior.AllowGet));
     }
 }
        /*increments likes number of the advice by javascript*/
        public JsonResult incrementAdviceNotificationByOne(Guid adviceID, string type)
        {
            try
            {
                Guid            currentPtID        = Guid.Parse(Session["patientID"].ToString());
                patient         currentPt          = db.patients.SingleOrDefault(p => p.id == currentPtID);
                commentOnAdvice isPatientCommented = db.commentOnAdvices.FirstOrDefault(c => c.patientID == currentPtID && c.adviceID == adviceID);
                if (isPatientCommented != null)
                {
                    switch (type)
                    {
                    case "share": isPatientCommented.share = true; break;

                    case "like":
                        if (isPatientCommented.like == true)
                        {
                            isPatientCommented.like = false;
                        }
                        else
                        {
                            isPatientCommented.like = true;
                            if (isPatientCommented.seen == false)
                            {
                                isPatientCommented.seen = true;
                            }
                        }
                        break;

                    case "seen": isPatientCommented.seen = true; break;
                    }
                    db.Entry(isPatientCommented).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    return(Json(true, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    commentOnAdvice newcomment = new commentOnAdvice();
                    newcomment.id        = Guid.NewGuid();
                    newcomment.seen      = true;
                    newcomment.adviceID  = adviceID;
                    newcomment.patientID = currentPtID;
                    db.commentOnAdvices.Add(newcomment);
                    switch (type)
                    {
                    case "share": newcomment.share = true; break;

                    case "like": newcomment.like = true; break;

                    case "seen": newcomment.seen = true; break;
                    }
                    db.SaveChanges();
                    return(Json(true, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }