public new ActionResult Profile()
        {
            int     id      = SecurityUtilities.GetAuthenticatedUserID();
            Patient patient = db.Patients.Where(p => p.ID == id).FirstOrDefault();

            ViewBag.BloodGroupID = new SelectList(db.BloodGroups, "ID", "Name", patient.BloodGroupID);
            return(View(patient));
        }
        public ActionResult ChangeImg(HttpPostedFileBase upload)
        {
            // get user from database
            int id      = SecurityUtilities.GetAuthenticatedUserID();
            var patient = db.Patients.Where(p => p.ID == id).FirstOrDefault();

            if (upload != null && upload.ContentLength > 0)
            {
                // convert image to array of binary then store it into database
                patient.Img = new byte[upload.ContentLength];
                upload.InputStream.Read(patient.Img, 0, upload.ContentLength);
                db.SaveChanges();
            }
            //redirect to profile after changing profile picture
            return(RedirectToAction("Profile"));
        }
        public ActionResult Analysis(HttpPostedFileBase uploaded)
        {
            if (uploaded != null && uploaded.ContentLength > 0)
            {
                string extension = Path.GetExtension(uploaded.FileName);
                string pattern   = @".(jpg|JPG|jpeg|JPEG|png|PNG)$";
                if (Regex.IsMatch(extension, pattern))
                {
                    // convert image to array of binary
                    var Img = new byte[uploaded.ContentLength];
                    uploaded.InputStream.Read(Img, 0, uploaded.ContentLength);

                    List <string> result = new List <string>()
                    {
                        "Positive", "Negative"
                    };
                    Random         rnd   = new Random();
                    int            index = rnd.Next(2);
                    PatientHistory PH    = new PatientHistory()
                    {
                        ADate     = DateTime.Now.Date,
                        Img       = Img,
                        PatientID = SecurityUtilities.GetAuthenticatedUserID(),
                        Result    = result[index]
                    };
                    db.PatientHistories.Add(PH);
                    db.SaveChanges();
                    return(RedirectToAction("History"));
                }
                else
                {
                    ModelState.AddModelError("ImgError", "Only Images allowed .");
                }
            }
            ModelState.AddModelError("Error", "An error occured while checking your image .");
            return(View());
        }
        public ActionResult History()
        {
            int id = SecurityUtilities.GetAuthenticatedUserID();

            return(View(db.PatientHistories.Where(h => h.PatientID == id).ToList()));
        }