public JsonResult insert(string day = "", string hour = "", string minute = "", string timezoneoffset = "") { try { if (!string.IsNullOrEmpty(day) && !string.IsNullOrEmpty(hour) && !string.IsNullOrEmpty(timezoneoffset) && ((ConfigVars.NewInstance.slots.SlotDuration == "30" && !string.IsNullOrEmpty(minute)) || ConfigVars.NewInstance.slots.SlotDuration != "30")) { string result = ""; if (ConfigVars.NewInstance.slots.SlotDuration == "30") { result = lIAppointmentScheduleRepository.GetAvailability(HttpContext.Session.GetString("UserId"), day, hour, minute, timezoneoffset); } else { result = lIAppointmentScheduleRepository.GetAvailability(HttpContext.Session.GetString("UserId"), day, hour, timezoneoffset); } if (string.IsNullOrEmpty(result)) { if (ConfigVars.NewInstance.slots.SlotDuration == "30") { string res = lIAppointmentScheduleRepository.InsertAvailability(HttpContext.Session.GetString("UserId"), Utilities.getUserType(HttpContext.Session.GetString("UserType")), timezoneoffset, day, hour, minute); return(Json(new { result = res })); } else { string res = lIAppointmentScheduleRepository.InsertAvailability(HttpContext.Session.GetString("UserId"), Utilities.getUserType(HttpContext.Session.GetString("UserType")), timezoneoffset, day, hour); return(Json(new { result = res })); } } else { if (ConfigVars.NewInstance.slots.SlotDuration == "30") { List <AppointmentSchedule> lappointments = lIAppointmentScheduleRepository.CheckAppointmentSchedule(HttpContext.Session.GetString("UserId"), Utilities.getUserType(HttpContext.Session.GetString("UserType")), timezoneoffset, day, hour, minute); if (lappointments == null || (lappointments != null && lappointments.Count == 0)) { string res = lIAppointmentScheduleRepository.RemoveAvailability(HttpContext.Session.GetString("UserId"), Utilities.getUserType(HttpContext.Session.GetString("UserType")), timezoneoffset, day, hour, minute); return(Json(new { result = res })); } else { return(Json(new { result = "failure", appointments = lappointments })); } } else { List <AppointmentSchedule> lappointments = lIAppointmentScheduleRepository.CheckAppointmentSchedule(HttpContext.Session.GetString("UserId"), Utilities.getUserType(HttpContext.Session.GetString("UserType")), timezoneoffset, day, hour); if (lappointments == null || (lappointments != null && lappointments.Count == 0)) { string res = lIAppointmentScheduleRepository.RemoveAvailability(HttpContext.Session.GetString("UserId"), Utilities.getUserType(HttpContext.Session.GetString("UserType")), timezoneoffset, day, hour); return(Json(new { result = res })); } else { return(Json(new { result = "failure", appointments = lappointments })); } } } } } catch (Exception ex) { return(Json("")); } return(Json("")); }
public JsonResult bookappointment([FromBody] bookappointment pbookappointment, string sessionid) { string timezoneid = TimeZoneInfo.Local.SupportsDaylightSavingTime ? TimeZoneInfo.Local.DaylightName : TimeZoneInfo.Local.StandardName;//"US Eastern Standard Time";// try { if (!string.IsNullOrEmpty(sessionid) && pbookappointment != null && !string.IsNullOrEmpty(pbookappointment.UserID) && !string.IsNullOrEmpty(pbookappointment.DateTime)) { Patient lpatient = IPatient.GetPatientBySessionID(sessionid); if (lpatient != null) { User luser = lIUserRepository.getUser(pbookappointment.UserID); if (luser != null) { AppointmentSchedule lbookAppointment = lIAppointmentScheduleRepository.CheckAppointmentSchedule(pbookappointment.UserID, Utilities.getUserType(luser.Type.ToString()), Convert.ToDateTime(pbookappointment.DateTime)); if (lbookAppointment == null) { lbookAppointment = new AppointmentSchedule(); lbookAppointment.UserType = luser.Type == 1 ? "Support" : "Therapist"; lbookAppointment.UserId = luser.UserId; lbookAppointment.Datetime = Convert.ToDateTime(pbookappointment.DateTime); lbookAppointment.PatientId = lpatient.PatientId; lbookAppointment.SlotStatus = "Booked"; lbookAppointment.CallStatus = "Open"; lbookAppointment.CreateDate = DateTime.UtcNow; lbookAppointment.UpdateDate = DateTime.UtcNow; lbookAppointment.RecordedFile = ""; } else if (lbookAppointment != null && lbookAppointment.CallStatus == "Extra") { lbookAppointment.Datetime = Convert.ToDateTime(pbookappointment.DateTime); lbookAppointment.PatientId = lpatient.PatientId; lbookAppointment.SlotStatus = "Booked"; lbookAppointment.CallStatus = "Open"; lbookAppointment.UpdateDate = DateTime.UtcNow; } User pPatient = lIUserRepository.getUser(lpatient.PatientLoginId); User pTherapistorSupport = lIUserRepository.getUser(luser.UserId); if (pPatient != null && !string.IsNullOrEmpty(pPatient.Vseeid) && pTherapistorSupport != null && !string.IsNullOrEmpty(pTherapistorSupport.Vseeid)) { VSeeHelper vsee = new VSeeHelper(); dynamic resURI = vsee.GetURI(pTherapistorSupport.Vseeid, pTherapistorSupport.Password, pPatient.Vseeid); if (resURI != null) { lbookAppointment.VseeUrl = resURI; int _result = 0; if (!string.IsNullOrEmpty(lbookAppointment.AppointmentId)) { _result = lIAppointmentScheduleRepository.UpdateAppointment(lbookAppointment); } else { lbookAppointment.AppointmentId = Guid.NewGuid().ToString(); _result = lIAppointmentScheduleRepository.InsertAppointment(lbookAppointment); } if (_result > 0) { string content = "New appointment has booked.<br><a href='" + ConfigVars.NewInstance.url + "?ruserid=" + Utilities.EncryptText(pTherapistorSupport.UserId) + "&rtype=" + Utilities.EncryptText(pTherapistorSupport.Type.ToString()) + "&rpage=" + Utilities.EncryptText("appointment") + "'> Click to view</a>"; Smtp.SendGridEmail(luser.Email, "Appointment", content); return(Json(new { Status = (int)HttpStatusCode.OK, result = "success", TimeZone = timezoneid })); } else { return(Json(new { Status = (int)HttpStatusCode.Created, result = "not inserted", TimeZone = timezoneid })); } } else { return(Json(new { Status = (int)HttpStatusCode.Created, result = "not inserted", TimeZone = timezoneid })); } } else { return(Json(new { Status = (int)HttpStatusCode.Created, result = "not inserted", TimeZone = timezoneid })); } } else { return(Json(new { Status = (int)HttpStatusCode.BadRequest, result = "user record is not found", TimeZone = timezoneid })); } } else { return(Json(new { Status = (int)HttpStatusCode.BadRequest, result = "patient is not registered", TimeZone = timezoneid })); } } else { return(Json(new { Status = (int)HttpStatusCode.Created, result = "request string is not proper", TimeZone = timezoneid })); } } catch (Exception ex) { return(Json(new { Status = (int)HttpStatusCode.InternalServerError, result = "Internal server error", TimeZone = timezoneid })); } }