public ResponseModel SendMessageToCustomerForScheduleVisit([FromBody] AppointmentMaster appointmentMaster) { ResponseModel objResponseModel = new ResponseModel(); int result = 0; int statusCode = 0; string statusMessage = ""; try { string token = Convert.ToString(Request.Headers["X-Authorized-Token"]); Authenticate authenticate = new Authenticate(); authenticate = SecurityService.GetAuthenticateDataFromToken(_radisCacheServerAddress, SecurityService.DecryptStringAES(token)); CustomerChatCaller customerChatCaller = new CustomerChatCaller(); result = customerChatCaller.SendMessageToCustomerForVisit(new CustomerChatService(_connectionString), appointmentMaster, _ClientAPIUrl, authenticate.UserMasterID); statusCode = result > 0 ? (int)EnumMaster.StatusCode.Success : (int)EnumMaster.StatusCode.InternalServerError; statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode); objResponseModel.Status = true; objResponseModel.StatusCode = statusCode; objResponseModel.Message = statusMessage; objResponseModel.ResponseData = result; } catch (Exception) { throw; } return(objResponseModel); }
//Bhawana(30/09/2019) //Save AppointmentDate While creating new Appoinment protected virtual void SaveAppointmentDates(AppointmentMaster model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } var formData = this.Request.Form.ToDictionary(x => x.Key, x => x.Value.ToString()); String[] AppointmentDate = formData["AppointmentDates"].Split(","); String[] RowId = formData["RowId"].Split(","); for (int i = 0; i < AppointmentDate.Count(); i++) { var appointmentDates = new AppointmentDates(); appointmentDates.AppointmentDate = Convert.ToDateTime(AppointmentDate[i]); appointmentDates.AppointmentMasterId = model.Id; appointmentDates.AppointmentStatusId = (int)AppointmentStatus.Created; model.AppointmentDates.Add(appointmentDates); } _appointmentServices.UpdateAppointment(model); }
/// <summary> /// Schedule Visit /// </summary> /// <param name="AppointmentMaster"></param> /// <returns></returns> public List <AppointmentDetails> ScheduleVisit(AppointmentMaster appointmentMaster) { DataSet ds = new DataSet(); List <AppointmentDetails> lstAppointmentDetails = new List <AppointmentDetails>(); try { conn.Open(); MySqlCommand cmd = new MySqlCommand("SP_HSScheduleVisit", conn) { Connection = conn }; cmd.Parameters.AddWithValue("@Customer_ID", appointmentMaster.CustomerID); cmd.Parameters.AddWithValue("@Appointment_Date", appointmentMaster.AppointmentDate); cmd.Parameters.AddWithValue("@Slot_ID", appointmentMaster.SlotID); cmd.Parameters.AddWithValue("@Tenant_ID", appointmentMaster.TenantID); cmd.Parameters.AddWithValue("@Created_By", appointmentMaster.CreatedBy); cmd.Parameters.AddWithValue("@NOof_People", appointmentMaster.NOofPeople); cmd.Parameters.AddWithValue("@Mobile_No", appointmentMaster.MobileNo); cmd.CommandType = CommandType.StoredProcedure; //message = Convert.ToInt32(cmd.ExecuteScalar()); MySqlDataAdapter da = new MySqlDataAdapter { SelectCommand = cmd }; da.Fill(ds); if (ds != null && ds.Tables[0] != null) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { AppointmentDetails appointmentDetails = new AppointmentDetails(); appointmentDetails.AppointmentID = Convert.ToInt32(ds.Tables[0].Rows[i]["AppointmentID"]); appointmentDetails.CustomerName = ds.Tables[0].Rows[i]["CustomerName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["CustomerName"]); appointmentDetails.CustomerMobileNo = ds.Tables[0].Rows[i]["MobileNo"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["MobileNo"]); appointmentDetails.StoreName = ds.Tables[0].Rows[i]["StoreName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["StoreName"]); appointmentDetails.StoreAddress = ds.Tables[0].Rows[i]["StoreAddress"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["StoreAddress"]); appointmentDetails.NoOfPeople = ds.Tables[0].Rows[i]["NOofPeople"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["NOofPeople"]); appointmentDetails.StoreManagerMobile = ds.Tables[0].Rows[i]["StoreManagerMobile"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["StoreManagerMobile"]); lstAppointmentDetails.Add(appointmentDetails); } } // int response = SendMessageToCustomer( /*ChatID*/0, appointmentMaster.MobileNo, appointmentMaster.ProgramCode, appointmentMaster.MessageToReply,/*ClientAPIURL*/"",appointmentMaster.CreatedBy); } catch (Exception) { throw; } finally { if (conn != null) { conn.Close(); } } return(lstAppointmentDetails); }
public void DeleteAppointment(AppointmentMaster appointment) { if (appointment == null) { throw new ArgumentNullException(nameof(appointment)); } appointment.Deleted = true; UpdateAppointment(appointment); }
/// <summary> /// Updates the Appointment /// </summary> /// <param name="Appointment">Appointment</param> public void UpdateAppointment(AppointmentMaster appointment) { if (appointment == null) { throw new ArgumentNullException(nameof(appointment)); } _appointmentMasterRepository.Update(appointment); }
public IActionResult Create(AppointmentModel model) { ResultModel resultModel = new ResultModel(); var AppointmentData = new AppointmentMaster(); try { if (ModelState.IsValid) { if (model.ID == 0) { AppointmentData.HospitalId = model.HospitalId; AppointmentData.PatientName = model.PatientName; AppointmentData.MR = model.MR; _appointmentServices.InsertAppointment(AppointmentData); SaveAppointmentDates(AppointmentData, model._appointmentDates); resultModel.Message = ValidationMessages.Success; resultModel.Status = 1; resultModel.Response = "Appointment Created"; return(Ok(resultModel)); } else { var appointmentData = _appointmentServices.GetAppointmentById(model.ID); appointmentData.Id = model.ID; appointmentData.HospitalId = model.HospitalId; appointmentData.PatientName = model.PatientName; appointmentData.MR = model.MR; _appointmentServices.UpdateAppointment(appointmentData); SaveAppointmentDates(appointmentData, model._appointmentDates); resultModel.Message = ValidationMessages.Success; resultModel.Status = 1; resultModel.Response = "Appointment Edited"; return(Ok(resultModel)); } } else { resultModel.Message = ValidationMessages.Failure; resultModel.Status = 0; resultModel.Response = "Appointment not created"; return(Ok(resultModel)); } } catch (Exception e) { _appointmentServices.DeleteAppointment(AppointmentData); return(Ok(model)); } }
public int SendMessageToCustomerForVisit(AppointmentMaster appointmentMaster, string ClientAPIURL, int CreatedBy) { MySqlCommand cmd = new MySqlCommand(); int resultCount = 0; //CustomerChatModel ChatMessageDetails = new CustomerChatModel(); ClientCustomSendTextModel SendTextRequest = new ClientCustomSendTextModel(); string ClientAPIResponse = string.Empty; try { string textToReply = "Dear" + appointmentMaster.CustomerName + ",Your Visit for Our Store is schedule On" + appointmentMaster.AppointmentDate + "On Time Between" + appointmentMaster.TimeSlot; #region call client api for sending message to customer SendTextRequest.To = appointmentMaster.MobileNo; SendTextRequest.textToReply = textToReply; SendTextRequest.programCode = appointmentMaster.ProgramCode; string JsonRequest = JsonConvert.SerializeObject(SendTextRequest); ClientAPIResponse = CommonService.SendApiRequest(ClientAPIResponse + "api/ChatbotBell/SendText", JsonRequest); // response binding pending as no response structure is provided yet from client------ //-------- #endregion //if (ChatID > 0) //{ // ChatMessageDetails.ChatID = ChatID; // ChatMessageDetails.Message = Message; // ChatMessageDetails.ByCustomer = false; // ChatMessageDetails.ChatStatus = 1; // ChatMessageDetails.StoreManagerId = CreatedBy; // ChatMessageDetails.CreatedBy = CreatedBy; // resultCount = SaveChatMessages(ChatMessageDetails); //} } catch (Exception) { throw; } return(resultCount); }
protected virtual void SaveAppointmentDates(AppointmentMaster model, List <AppointmentDatesModel> appointmentDatesModels) { if (model == null) { throw new ArgumentNullException(nameof(model)); } foreach (var item in appointmentDatesModels) { if (item.ID == 0) { var appointmentDates = new AppointmentDates(); appointmentDates.AppointmentDate = Convert.ToDateTime(item.AppointmentDate); appointmentDates.AppointmentStatusId = (int)AppointmentStatus.Created; appointmentDates.AppointmentMasterId = model.Id; model.AppointmentDates.Add(appointmentDates); } } _appointmentServices.UpdateAppointment(model); }
public ResponseModel ScheduleVisit([FromBody] AppointmentMaster appointmentMaster) { ResponseModel objResponseModel = new ResponseModel(); List <AppointmentDetails> appointmentDetails = new List <AppointmentDetails>(); int statusCode = 0; string statusMessage = ""; try { string token = Convert.ToString(Request.Headers["X-Authorized-Token"]); Authenticate authenticate = new Authenticate(); authenticate = SecurityService.GetAuthenticateDataFromToken(_radisCacheServerAddress, SecurityService.DecryptStringAES(token)); appointmentMaster.CreatedBy = authenticate.UserMasterID; appointmentMaster.TenantID = authenticate.TenantId; CustomerChatCaller customerChatCaller = new CustomerChatCaller(); appointmentDetails = customerChatCaller.ScheduleVisit(new CustomerChatService(_connectionString), appointmentMaster); statusCode = appointmentDetails.Count == 0 ? (int)EnumMaster.StatusCode.RecordNotFound : (int)EnumMaster.StatusCode.Success; statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode); objResponseModel.Status = true; objResponseModel.StatusCode = statusCode; objResponseModel.Message = statusMessage; objResponseModel.ResponseData = appointmentDetails; } catch (Exception) { throw; } return(objResponseModel); }
/// <summary> /// Schedule Visit /// </summary> /// <param name=""></param> /// <returns></returns> public List <AppointmentDetails> ScheduleVisit(ICustomerChat customerChatStatus, AppointmentMaster appointmentMaster) { _customerChat = customerChatStatus; return(_customerChat.ScheduleVisit(appointmentMaster)); }
public int SendMessageToCustomerForVisit(ICustomerChat customerChat, AppointmentMaster appointmentMaster, string ClientAPIURL, int CreatedBy) { _customerChat = customerChat; return(_customerChat.SendMessageToCustomerForVisit(appointmentMaster, ClientAPIURL, CreatedBy)); }
public void Add(AppointmentMaster entity) { _eFRepository.Add(entity); _eFRepository.Save(); }
public ActionResult ConfirmAppointment(FormCollection fc) { string uniqueid = fc["uniqueId"]; string vanue = fc["vanue"]; int vanueid = 0; var data = from asd in _db.vanueMasters where asd.vanueName == vanue select new { asd.pKey }; foreach (var item in data) { vanueid = item.pKey; } DateTime tempdate = Convert.ToDateTime(fc["selecteddate"]); int dateid = 0; var data1 = from asd in _db.AppointmentDateMasters where (asd.date == tempdate && asd.vanue == vanueid)select new { asd.pKey }; foreach (var item in data1) { dateid = item.pKey; } int datehash = dateid; int timehash = 0; switch (fc["selectedtime"]) { case "10:0-10:30": timehash = 1; break; case "10:30-11:0": timehash = 2; break; case "11:0-11:30": timehash = 3; break; case "11:30-12:0": timehash = 4; break; case "12:30-13:0": timehash = 5; break; case "13:0-13:30": timehash = 6; break; case "13:30-14:0": timehash = 7; break; case "14:0-14:30": timehash = 8; break; case "14:30-15:0": timehash = 9; break; case "15:0-15:30": timehash = 10; break; case "15:30-16:0": timehash = 11; break; case "16:0-16:30": timehash = 12; break; case "16:30-17:0": timehash = 13; break; case "17:0-17:30": timehash = 14; break; case "17:30-18:0": timehash = 15; break; default: break; } var datedata = from qwe in _db.AppointmentDateMasters where qwe.pKey == datehash && qwe.vanue == vanueid select qwe; int temptotalcount = 0; DateTime date = DateTime.Now; foreach (var item in datedata) { date = item.date; temptotalcount = (int)item.totalCount; } AppointmentDateMaster _appointmentdatedaster = new AppointmentDateMaster() { pKey = datehash, date = date, totalCount = (temptotalcount + 1), vanue = vanueid }; _db.Configuration.ValidateOnSaveEnabled = false; try { var data2 = _db.AppointmentDateMasters.Find(datehash); _db.Entry(data2).CurrentValues.SetValues(_appointmentdatedaster); _db.Entry(data2).State = EntityState.Modified; //_db.AppointmentDateMasters.Attach(_appointmentdatedaster); //_db.Entry(_appointmentdatedaster).Property(asd => asd.totalCount).IsModified = true; _db.SaveChanges(); } finally { _db.Configuration.ValidateOnSaveEnabled = true; } string time = null; DateTime temp = new DateTime(2016, 05, 13, 09, 30, 00); if (timehash < 5) { time = (temp.AddMinutes(timehash * 30)).Hour.ToString() + ":" + (temp.AddMinutes(timehash * 30)).Minute.ToString() + "-" + (temp.AddMinutes((timehash + 1) * 30)).Hour.ToString() + ":" + (temp.AddMinutes((timehash + 1) * 30)).Minute.ToString(); } else { time = (temp.AddMinutes((timehash + 1) * 30)).Hour.ToString() + ":" + (temp.AddMinutes((timehash + 1) * 30)).Minute.ToString() + "-" + (temp.AddMinutes((timehash + 2) * 30)).Hour.ToString() + ":" + (temp.AddMinutes((timehash + 2) * 30)).Minute.ToString(); } var timedata = from zxc in _db.AppointmentTimeMasters where zxc.date == datehash && zxc.timeSlot == timehash select zxc; int count = timedata.Count(); int timepkey = 0; if (count <= 0) { AppointmentTimeMaster _appointmenttimemaster = new AppointmentTimeMaster() { date = datehash, timeSlot = timehash, totalCount = 1 }; _db.AppointmentTimeMasters.Add(_appointmenttimemaster); _db.SaveChanges(); timepkey = _appointmenttimemaster.pkey; } else { int totaltimecount = 0; foreach (var item in timedata) { timepkey = item.pkey; totaltimecount = (int)item.totalCount; } AppointmentTimeMaster _appointmenttimemaster = new AppointmentTimeMaster() { pkey = timepkey, totalCount = (totaltimecount + 1) }; _db.Configuration.ValidateOnSaveEnabled = false; try { _db.AppointmentTimeMasters.Attach(_appointmenttimemaster); _db.Entry(_appointmenttimemaster).Property(zxc => zxc.totalCount).IsModified = true; _db.SaveChanges(); } finally { _db.Configuration.ValidateOnSaveEnabled = true; } } var userdata = from qwe in _db.ErtoMasters where qwe.uniqueId == uniqueid select new { qwe.id }; int id = 0; foreach (var item in userdata) { id = item.id; } AppointmentMaster _appointmentmaster = new AppointmentMaster() { id = id, timeOfAppointment = timepkey }; _db.AppointmentMasters.Add(_appointmentmaster); _db.SaveChanges(); string email = null; var contectdata = from lkj in _db.ContectMasters where lkj.id == id && lkj.isPrimary == true select lkj; foreach (var item in contectdata) { email = item.emailId; } MailMessage _mailmessage = new MailMessage("*****@*****.**", email); _mailmessage.Subject = "Appointment"; _mailmessage.Body = "<p>Appointment Letter</p></br><table style=\"width:20%\"><tr><td> Vanue </td><td> " + vanue + "</td></tr><tr><td> Date </td><td>" + date + "</td></tr><tr><td> Time </td><td>" + time + "</td></tr></table></br><p> Thank You.</p>"; _mailmessage.IsBodyHtml = true; SmtpClient sc = new SmtpClient(); sc.Send(_mailmessage); return(RedirectToAction("ThankYou", "LearningLicense")); }
public IActionResult Create(AppointmentModel model) { if (!(bool)SharedData.isAppointmentMenuAccessible) { return(AccessDeniedView()); } var appointmentId = 0; try { if (ModelState.IsValid) { var AppointmentData = new AppointmentMaster(); //Insert Appointment if (model.Id == 0) { AppointmentData.HospitalId = model.HospitalId; AppointmentData.PatientName = model.PatientName; AppointmentData.MR = model.MR; AppointmentData.CreatedOn = DateTime.UtcNow; AppointmentData.Deleted = false; _appointmentServices.InsertAppointment(AppointmentData); appointmentId = AppointmentData.Id; SaveAppointmentDates(AppointmentData); AddNotification(NotificationMessage.TitleSuccess, NotificationMessage.msgAddAppointment, NotificationMessage.TypeSuccess); return(RedirectToAction("Index", "Appointment")); } //EditAppointment else { AppointmentData.Id = model.Id; AppointmentData.HospitalId = model.HospitalId; AppointmentData.PatientName = model.PatientName; AppointmentData.MR = model.MR; _appointmentServices.UpdateAppointment(AppointmentData); AddNotification(NotificationMessage.TitleSuccess, NotificationMessage.msgEditAppointment, NotificationMessage.TypeSuccess); return(RedirectToAction("Index", "Appointment")); } } else { model.AvailableHospitals.Add(new SelectListItem { Text = "Select Hospitals", Value = "0" }); foreach (var c in _hospitalServices.GetAllHospital()) { model.AvailableHospitals.Add(new SelectListItem { Text = _encryptionService.DecryptText(c.HospitalName), Value = c.Id.ToString(), Selected = c.Id == model.HospitalId }); } if (model.Id != 0) { var appointment = _appointmentServices.GetAppointmentById(model.Id); foreach (var ApointmentDate in appointment.AppointmentDates) { var appointmentDate = new AppointmentDatesModel { AppointmentDates = ApointmentDate.AppointmentDate, AppointmentMasterId = ApointmentDate.AppointmentMasterId, Id = ApointmentDate.Id }; model._appointmentDates.Add(appointmentDate); } } return(View(model)); } } catch (Exception e) { var AppointmentData = _appointmentServices.GetAppointmentById(appointmentId); _appointmentServices.DeleteAppointment(AppointmentData); model.AvailableHospitals.Add(new SelectListItem { Text = "Select Hospitals", Value = "0" }); foreach (var c in _hospitalServices.GetAllHospital()) { model.AvailableHospitals.Add(new SelectListItem { Text = _encryptionService.DecryptText(c.HospitalName), Value = c.Id.ToString(), Selected = c.Id == model.HospitalId }); } AddNotification(NotificationMessage.TitleError, NotificationMessage.ErrorMsg, NotificationMessage.TypeError); return(View(model)); } }