public ActionResult ADetails(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Error", "Index", new { err = "Id is not available!" }));
            }
            AppointmentManage appointmentManage = db.AppointmentManages.Find(id);

            if (appointmentManage == null)
            {
                return(RedirectToAction("Error", "Index", new { err = "Data is not available!" }));
            }
            return(View(appointmentManage));
        }
        // GET: Admin/AppointmentManages/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Error", "Dashboard", new { err = "Id is not Avalible!!" }));
            }
            AppointmentManage appointmentManage = db.AppointmentManages.Find(id);

            if (appointmentManage == null)
            {
                return(RedirectToAction("Error", "Dashboard", new { err = "Data is not Avalible!!" }));
            }
            return(View(appointmentManage));
        }
        // GET: Admin/AppointmentManages/Edit/5
        public ActionResult AEdit(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Error", "Index", new { err = "Id is not Avalible!!" }));
            }
            AppointmentManage appointmentManage = db.AppointmentManages.Find(id);

            if (appointmentManage == null)
            {
                return(RedirectToAction("Error", "Index", new { err = "Data is not Avalible!!" }));
            }
            ViewBag.RefDid = new SelectList(db.DoctorManages, "DrId", "DrName", appointmentManage.RefDid);
            ViewBag.RefPid = new SelectList(db.PatientManages, "Pid", "Pname", appointmentManage.RefPid);
            return(View(appointmentManage));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            try
            {
                AppointmentManage appointmentManage = db.AppointmentManages.Find(id);
                db.AppointmentManages.Remove(appointmentManage);
                db.SaveChanges();
                TempData["msg"] = "Appointment Cancle!!";
            }
            catch (Exception ex)
            {
                TempData["err"] = ex.Message;
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult ACreate([Bind(Include = "RefPid,RefDid,AppointmentStartDate,AppointmentEndDate,Purpose,Status,DocumentUpload,Cretedby,Modifiedby,Creteddate,Modifieddate,Aid")] AppointmentManage appointmentManage, HttpPostedFileBase DocumentUpload)
        {
            string dirPath = Server.MapPath("~/Content/Admin/Upload");

            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath);
            }
            string strDateTime = System.DateTime.Now.ToString("ddMMyyyyHHMMss");
            string filename    = "Report_" + strDateTime + "." + DocumentUpload.FileName.Split('.')[1];
            string filepath    = dirPath + "\\" + filename;

            DocumentUpload.SaveAs(filepath);


            ViewBag.message = "File Uploaded!";
            appointmentManage.DocumentUpload = filename;
            if (ModelState.IsValid)
            {
                try
                {
                    var CretedName = Convert.ToString(Session["AdminName"]);
                    appointmentManage.Cretedby   = CretedName;
                    appointmentManage.Creteddate = DateTime.Now;
                    db.AppointmentManages.Add(appointmentManage);
                    db.SaveChanges();
                    TempData["msg"] = "Appointment Set!!";
                    return(RedirectToAction("AIndex"));
                }
                catch (Exception ex)
                {
                    TempData["err"] = ex.Message;
                }
            }

            ViewBag.RefDid = new SelectList(db.DoctorManages, "DrId", "DrName", appointmentManage.RefDid);
            ViewBag.RefPid = new SelectList(db.PatientManages, "Pid", "Pname", appointmentManage.RefPid);
            return(View(appointmentManage));
        }
 public ActionResult AEdit([Bind(Include = "RefPid,RefDid,AppointmentStartDate,AppointmentEndDate,Purpose,Status,DocumentUpload,Cretedby,Modifiedby,Creteddate,Modifieddate,Aid")] AppointmentManage appointmentManage)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var ModifiedName = Convert.ToString(Session["AdminName"]);
             appointmentManage.Modifiedby      = ModifiedName;
             appointmentManage.Modifieddate    = DateTime.Now;
             db.Entry(appointmentManage).State = EntityState.Modified;
             db.SaveChanges();
             TempData["msg"] = "Appointment Updated!!";
             return(RedirectToAction("AIndex"));
         }
         catch (Exception ex)
         {
             TempData["err"] = ex.Message;
         }
     }
     ViewBag.RefDid = new SelectList(db.DoctorManages, "DrId", "DrName", appointmentManage.RefDid);
     ViewBag.RefPid = new SelectList(db.PatientManages, "Pid", "Pname", appointmentManage.RefPid);
     return(View(appointmentManage));
 }