Пример #1
0
        public void SentEmailNotification(AppointmentModel model, PractitionerBaseViewModel ptResult)
        {
            string mailFrom = ConstantHelper.AppSettings.MailFrom;
            string userName = ConstantHelper.AppSettings.UserName;
            string password = ConstantHelper.AppSettings.Password;

            try
            {
                PatientData patientDataLayer = new PatientData();
                string      patientEmail     = patientDataLayer.GetPatientEmail(model.PatientId);
                if (!String.IsNullOrEmpty(patientEmail))
                {
                    //Sent notification email to patient
                    string patientEmailSubject = ConstantHelper.Email.AppointmentVerification.AppointmentMadeSubject;
                    string patientEmailBody    = ConstantHelper.Email.AppointmentVerification.AppointmentMadeBody;
                    //replace with appointment details
                    DateTime tempAppointmentDateTime = Convert.ToDateTime(model.AppointmentDate.ToString());
                    string   appointmentDetailsTable = "<table><caption>Appointment Details</caption><tr><th>Appointment Date</th><td>" + tempAppointmentDateTime.ToString("dd/MM/yyyy") + "</td></tr><tr><th>Appointment Time</th><td>" + tempAppointmentDateTime.ToString("hh:mm tt") + "</td></tr><tr><th>Company</th><td>" + ptResult.CompanyName + "</td></tr><tr><th>City</th><td>" + ptResult.City + "</td></tr><tr><th>Postal Code</th><td>" + ptResult.PostalCode + "</td></tr><tr><th>State</th><td>" + ptResult.State + "</td></tr><tr><th>Appointment Description</th><td>" + model.Description + "</td></tr><tr><th>Appointment Remarks</th><td>" + model.Remarks + "</td></tr></table>";
                    patientEmailBody = patientEmailBody.Replace(ConstantHelper.Email.Keyword.AppointmentDetails, appointmentDetailsTable);
                    EmailHelper.SentMail(mailFrom, patientEmail, patientEmailSubject, patientEmailBody, userName, password);
                }

                PractitionerData practitionerDataLayer = new PractitionerData();
                string           practitionerEmail     = practitionerDataLayer.GetPractitionerEmail(model.PractitionerId);
                if (!String.IsNullOrEmpty(practitionerEmail))
                {
                    //Sent notification email to practitioner
                    string practitionerEmailSubject = ConstantHelper.Email.AppointmentVerification.NewAppointmentSubject;
                    string practitionerEmailBody    = ConstantHelper.Email.AppointmentVerification.NewAppointmentBody;
                    //replace maybe link to practitionerLogin
                    string practitionerLoginPage = "<a href='" + ConstantHelper.AppSettings.RootSiteUrl + ConstantHelper.API.Practitioner.PractitionerLogin + "'>Practitioner Login Page</a>";
                    practitionerEmailBody = practitionerEmailBody.Replace(ConstantHelper.Email.Keyword.PractitionerLoginPage, practitionerLoginPage);
                    EmailHelper.SentMail(mailFrom, practitionerEmail, practitionerEmailSubject, practitionerEmailBody, userName, password);
                }
            }
            catch (Exception err)
            {
                new LogHelper().LogMessage("PatientBusiness.SentEmailNotification : " + err);
            }
        }