public ActionResult UpdateAvatar(DoctorIndex post)
        {
            resetViewBagMessages();
            HttpPostedFileBase ImageUrl = Request.Files[0];

            if (ImageUrl != null && ImageUrl.ContentLength > 0)
            {
                var fileName = Path.GetFileName(ImageUrl.FileName);
                var path     = Path.Combine(Server.MapPath("~/Content/images/avatar/"), fileName);
                ImageUrl.SaveAs(path);

                DoctorModel doctor = DataBase.Session.Load <DoctorModel>(post.Doctor.ID);
                //delete Previous file
                if (System.IO.File.Exists(doctor.Image_url))
                {
                    System.IO.File.Delete(doctor.Image_url);
                }
                //updating new file
                doctor.Image_url  = path;
                doctor.Image_name = fileName;
                DataBase.Session.Update(doctor);
                Session["DOCAVATAR"] = fileName;
                if (System.IO.File.Exists(path))
                {
                    message = "Avatar Sucessfully Updated";
                }
            }
            else
            {
                err = "Error Occured while updating Avatar";
            }
            return(RedirectToAction("Index"));
        }
        public ActionResult UpdateInfo(DoctorIndex post)
        {
            resetViewBagMessages();
            DataBase.Session.Update(post.Doctor);
            message = "Personal Info Updated Sucessfully";

            return(RedirectToAction("Index"));
        }
        public ActionResult DoctorProfile(int?DocID)
        {
            resetViewBagMessages();
            DoctorIndex model = new DoctorIndex();

            model.Doctor      = DataBase.Session.QueryOver <DoctorModel>().Where(x => x.ID == DocID).SingleOrDefault();
            model.PatientList = getPatientList(DocID);
            return(View(model));
        }
        // GET: Doctor
        public ActionResult Index() //Profile
        {
            DoctorIndex model = new DoctorIndex();

            model.Doctor      = DataBase.Session.QueryOver <DoctorModel>().Where(x => x.ID == Convert.ToInt32(Session["DOCID"])).SingleOrDefault();
            model.PatientList = getPatientList();
            ViewBag.msg       = message;
            ViewBag.err       = err;
            return(View(model));
        }
 public ActionResult UpdatePassword(DoctorIndex post)
 {
     resetViewBagMessages();
     if (post.OldPassword != DataBase.Session.QueryOver <DoctorModel>().Where(x => x.ID == post.Doctor.ID).SingleOrDefault().Password)
     {
         err = "Old Password you enter is not correct";
     }
     else if (post.NewPassword == null || post.NewPassword != post.CnfrmPassword)
     {
         err = "Password do not match";
     }
     else
     {
         message = "Password Sucessfully Updated";
         DoctorModel temp = DataBase.Session.Load <DoctorModel>(post.Doctor.ID);
         temp.Password = post.NewPassword;
         DataBase.Session.Update(temp);
     }
     return(RedirectToAction("Index"));
 }