public ActionResult Delete(DoctorAndNetUsers model)
        {
            ViewBag.Message = "Appointment Cancelled !";
            AllAppointment deleteAppointment = myEntities.AllAppointments.FirstOrDefault(a => a.AptId == model.AllAppointment.AptId);

            myEntities.AllAppointments.Remove(deleteAppointment);
            myEntities.SaveChanges();
            return(View("ConfirmAppointment"));
        }
        public ActionResult Schedule(int id)
        {
            ViewBag.Slots = new SelectList(myEntities.doctorSlots.Where(d => d.doctorId == id), "slotTimes", "slotTimes");
            var doctor = myEntities.Doctors.Where(d => d.DocId == id).FirstOrDefault();
            DoctorAndNetUsers doctorAndNetUser = new DoctorAndNetUsers();

            doctorAndNetUser.Doctor                  = doctor;
            doctorAndNetUser.AllAppointment          = new AllAppointment();
            doctorAndNetUser.AllAppointment.SlotDate = Convert.ToDateTime(DateTime.Now);
            doctorAndNetUser.AllAppointment.Slots    = "";

            return(View(doctorAndNetUser));
        }
        public ActionResult Delete(int id)
        {
            var appointment = myEntities.AllAppointments.SingleOrDefault(a => a.AptId == id);
            int dId         = int.Parse(Request.QueryString["dId"]);

            ViewBag.Slots = new SelectList(myEntities.doctorSlots.Where(d => d.doctorId == dId), "slotTimes", "slotTimes");
            var doctor = myEntities.Doctors.SingleOrDefault(d => d.DocId == dId);
            var doctorAndAppointment = new DoctorAndNetUsers
            {
                AllAppointment = appointment,
                Doctor         = doctor
            };

            return(View(doctorAndAppointment));
        }
        public ActionResult ConfirmAppointment(DoctorAndNetUsers model)
        {
            string   UserName    = User.Identity.Name;
            int      DoctorId    = model.Doctor.DocId;
            DateTime AptDate     = Convert.ToDateTime(model.AllAppointment.SlotDate);
            string   AptTime     = model.AllAppointment.Slots;
            var      existsOrNot = myEntities.AllAppointments.Where(c => c.DoctorId == DoctorId && c.SlotDate == AptDate && c.Slots == AptTime);
            var      count       = existsOrNot.Count();

            if (count == 0)
            {
                if (AptTime == null)
                {
                    ViewBag.Slots = new SelectList(myEntities.doctorSlots.Where(d => d.doctorId == DoctorId), "slotTimes", "slotTimes");
                    var doctor = myEntities.Doctors.Where(d => d.DocId == DoctorId).FirstOrDefault();
                    DoctorAndNetUsers doctorAndNetUser = new DoctorAndNetUsers();
                    doctorAndNetUser.Doctor                  = doctor;
                    doctorAndNetUser.AllAppointment          = new AllAppointment();
                    doctorAndNetUser.AllAppointment.SlotDate = Convert.ToDateTime(DateTime.Now);
                    doctorAndNetUser.AllAppointment.Slots    = "";
                    return(View("Schedule", doctorAndNetUser));
                }
                else
                {
                    AllAppointment appointment = new AllAppointment();
                    appointment.UserName       = UserName;
                    appointment.DoctorId       = DoctorId;
                    appointment.SlotDate       = AptDate;
                    appointment.Slots          = AptTime;
                    appointment.DrAvailability = "yes";
                    myEntities.AllAppointments.Add(appointment);
                    myEntities.SaveChanges();
                    ViewBag.Message = "Appointment Confirmed !";
                    return(View());
                }
            }
            else
            {
                ViewBag.Message = "Slots not Available Now !";
                return(View());
            }
        }
 public ActionResult Edit(int id)
 {
     try
     {
         var appointment = myEntities.AllAppointments.SingleOrDefault(a => a.AptId == id);
         int dId         = int.Parse(Request.QueryString["dId"]);
         ViewBag.Slots = new SelectList(myEntities.doctorSlots.Where(d => d.doctorId == dId), "slotTimes", "slotTimes");
         var doctor = myEntities.Doctors.SingleOrDefault(d => d.DocId == dId);
         var doctorAndAppointment = new DoctorAndNetUsers
         {
             AllAppointment = appointment,
             Doctor         = doctor
         };
         return(View(doctorAndAppointment));
     }
     catch (Exception)
     {
         throw new Exception("Problem with updation.");;
     }
 }
        public ActionResult Edit(DoctorAndNetUsers model)
        {
            string   UserName    = User.Identity.Name;
            int      DoctorId    = model.Doctor.DocId;
            DateTime AptDate     = Convert.ToDateTime(model.AllAppointment.SlotDate);
            string   AptTime     = model.AllAppointment.Slots;
            var      existsOrNot = myEntities.AllAppointments.Where(c => c.DoctorId == DoctorId && c.SlotDate == AptDate && c.Slots == AptTime);
            var      count       = existsOrNot.Count();

            if (count == 0)
            {
                AllAppointment appointment = myEntities.AllAppointments.FirstOrDefault(a => a.AptId == model.AllAppointment.AptId);
                appointment.SlotDate = AptDate;
                appointment.Slots    = AptTime;
                myEntities.SaveChanges();
                ViewBag.Message = "Appointment Confirmed !";
            }
            else
            {
                ViewBag.Message = "Slots not Available Now !";
            }
            return(View("ConfirmAppointment"));
        }