public ActionResult View_App_Details()
        {
            using (KIITEntities db = new KIITEntities())
            {
                int memid = Convert.ToInt32(Session["Memberid"]);
                var p     = db.Patients.Where(a => a.MemberId == memid).Select(a => new { a.FirstName, a.PatientId }).SingleOrDefault();
                var da    = db.DoctorAppointments.Where(a => a.PatientId == p.PatientId);

                List <DoctorAppointmentViewModel> lst = new List <DoctorAppointmentViewModel>();
                foreach (var item in da)
                {
                    var d = db.Doctors.Where(a => a.DoctorId == item.DoctorId).SingleOrDefault();
                    lst.Add(new DoctorAppointmentViewModel
                    {
                        PatientName       = p.FirstName,
                        DoctorName        = d.FirstName,
                        Subject           = item.Subject,
                        Description       = item.Description,
                        AppointmentDate   = item.AppointmentDate,
                        AppointmentStatus = item.AppointmentStatus
                    });
                }
                DoctorAppointmentViewModel model = new DoctorAppointmentViewModel();
                model.lstApp = lst;
                return(View(model));
            }
        }
        public ActionResult Doctor_Appointment()
        {
            DoctorAppointmentViewModel model = new DoctorAppointmentViewModel();

            model.lstDocs = CommonData.GetDocs();

            return(View(model));
        }
        public ActionResult Appointment(string id = "", int AppointmentId = 0, string status = "", string fromDate = "", string toDate = "", string msg = "")
        {
            int DoctorId = int.Parse(new EncryptDecrypt().Decrypt(id));

            DoctorAppointmentViewModel data = new DoctorAppointmentViewModel();

            AppointmentAPIController aController = new AppointmentAPIController();
            ReturnObject             ro          = new ReturnObject();

            using (var db = new ddiarydbEntities())
            {
                var doctor = db.Doctor_Master.Where(x => x.Doctor_id == DoctorId).FirstOrDefault();

                if (AppointmentId > 0)
                {
                    ro = aController.Update_Appointment(AppointmentId, status, msg);
                }

                var appointments = new List <Appointment>();

                ro = aController.Get_Appointments(0, DoctorId, fromDate, toDate);

                try
                {
                    appointments = (List <Appointment>)ro.data2;
                }
                catch (Exception)
                {
                    appointments = null;
                }

                if (doctor != null)
                {
                    data.Doctor = new DoctorViewModel().DoctorModel_to_ViewModel(doctor);

                    data.Appointments = new List <AppointmentViewModel>();
                    foreach (var item in appointments)
                    {
                        var temp = item.PatientName.Split(' ');
                        if (temp.Length > 1)
                        {
                            item.SessionId = temp[0].Substring(0, 1) + temp[1].Substring(0, 1);
                        }
                        else
                        {
                            item.SessionId = temp[0].Substring(0, 1);
                        }

                        data.Appointments.Add(new AppointmentViewModel().AppointmentModel_to_ViewModel(item));
                    }
                }
            }

            return(View(data));
        }
        public ActionResult Doctor_Appointment(DoctorAppointmentViewModel model)
        {
            int memid = Convert.ToInt32(Session["Memberid"]);
            DoctorAppointmentViewModel model_post = new DoctorAppointmentViewModel();

            model_post.lstDocs = CommonData.GetDocs();
            if (model.PatientName != null && model.Subject != null && model.DoctorId != 0)
            {
                KIITEntities db   = new KIITEntities();
                int          p_id = db.Patients.Where(a => a.MemberId == memid).Select(a => a.PatientId).SingleOrDefault();
                db.InsertAppointment(p_id, model.DoctorId, model.Subject, model.Description, model.AppointmentDate);
                return(View(model_post));
            }
            else
            {
                return(View(model_post));
            }
        }