Exemplo n.º 1
0
        public async Task <ActionResult> CreateAppointmentOld(PatientAppointmentOldViewModel appointmentold)
        {
            bool success = false;



            if (!ModelState.IsValid)
            {
                var patientAppointment =
                    new PatientAppointmentOldViewModel
                {
                    PhysicianListItems = _appointmentServices.GetAllDoctors()
                };

                return(PartialView("_CreateAppointment", patientAppointment));
            }

            //var context = GlobalHost.ConnectionManager.GetHubContext<AppointHub>();

            var appointment = new Appointment()
            {
                AppointDate = appointmentold.AppointDate,
                Pat_Id      = appointmentold.PatientId,
                Phys_id     = appointmentold.PhysId,
                PriorNo     = 1,
                Status      = false,
                IsCancelled = false
            };


            var hasAppointmentExist =
                _appointmentServices.CheckAppointment(appointmentold.PatientId, appointmentold.PhysId, appointmentold.AppointDate);



            if (!hasAppointmentExist)
            {
                success = true;

                _appointmentServices.InsertAppointment(appointment);

                appointHub = new AppointHub();



                _unitofwork.Commit();

                var appointSchedulebydoctor = await _appointmentServices.GetAllAppointmentList();

                if (appointment.Phys_id != null)
                {
                    appointHub.SendAppointment(appointment.Phys_id, appointSchedulebydoctor.Where(t => t.PhyId == appointment.Phys_id && t.AppointDate == appointment.AppointDate && !t.BlStat).ToList());
                }
            }


            var url = Url.Action("GetAppointment_By_Doctor", "Appointment", new { id = appointment.Phys_id, appdate = appointment.AppointDate });


            return(Json(new { success = success, url = url }, JsonRequestBehavior.AllowGet));
        }