private Boolean SendConfirmationEmail() { bool blnEmailSent = false; bool blnIsAppointment = false; try { if(txtPreferredDay.Value.Trim() != "" && drpTreatment.SelectedValue.ToString() != "" && drpTreatment.SelectedValue.ToString() != Translate.Text("Select")) { blnIsAppointment = true; } string strEmailSubject = blnIsAppointment ? EmailSubjects.HealthAndBeautyAppointmentConfirmation : EmailSubjects.HealthAndBeautyEnquiryConfirmation; //string strEmailTemplate = blnIsAppointment ? EmailTemplates.HealthAndBeautyAppointmentConfirmation : EmailTemplates.HealthAndBeautyEnquiryConfirmation; EmailItem EmailTemplate = blnIsAppointment ? (EmailItem)Sitecore.Context.Database.GetItem(EmailPaths.HealthAndBeautyAppointmentConfirmation) : (EmailItem)Sitecore.Context.Database.GetItem(EmailPaths.HealthAndBeautyEnquiryConfirmation); string strEmailFromAddress = Settings.WebsiteMailFromText; string strEmailToAddress = txtEmail.Value.Trim(); //Populate email text variables Hashtable objTemplateVariables = new Hashtable(); objTemplateVariables.Add("HomePageUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.HomePage)); objTemplateVariables.Add("FacilitiesAndClassesLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.FacilitiesAndClasses)); objTemplateVariables.Add("YourHealthLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.YourHealth)); objTemplateVariables.Add("MembershipsLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.Memberships)); objTemplateVariables.Add("PrivacyPolicyLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.PrivacyPolicy)); objTemplateVariables.Add("TermsAndConditionsLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.TermsAndConditions)); objTemplateVariables.Add("Copyright", Translate.Text("© Copyright ##Year## Virgin Active. All rights reserved.")); objTemplateVariables.Add("CustomerName", txtName.Value.Trim()); if (clubManager != null) { objTemplateVariables.Add("ClubManagerName", clubManager.Person.Firstname.Rendered + " " + clubManager.Person.Lastname.Rendered); } else { objTemplateVariables.Add("ClubManagerName", ""); } objTemplateVariables.Add("PreferredDay", txtPreferredDay.Value.Trim() != "" ? txtPreferredDay.Value.Trim() : "N/A"); objTemplateVariables.Add("PreferredTime", drpPreferredTime.SelectedValue.ToString() != "" && drpPreferredTime.SelectedValue.ToString() != Translate.Text("Select") ? drpPreferredTime.SelectedValue.ToString() : "N/A"); objTemplateVariables.Add("Treatment", drpTreatment.SelectedValue.ToString() != "" && drpTreatment.SelectedValue.ToString() != Translate.Text("Select") ? drpTreatment.SelectedValue.ToString() : "N/A"); objTemplateVariables.Add("ClubName", club.Clubname.Rendered); objTemplateVariables.Add("EmailSubject", strEmailSubject); objTemplateVariables.Add("EmailFromAddress", strEmailFromAddress); objTemplateVariables.Add("EmailToAddress", strEmailToAddress); objTemplateVariables.Add("YouTubeLinkUrl", Settings.YouTubeLinkUrl); objTemplateVariables.Add("TwitterLinkUrl", Settings.TwitterLinkUrl); objTemplateVariables.Add("FacebookLinkUrl", Settings.FacebookLinkUrl); objTemplateVariables.Add("McCormackMorrisonLinkUrl", Settings.McCormackMorrisonUrl); objTemplateVariables.Add("ImageRootUrl", Sitecore.Web.WebUtil.GetServerUrl()); objTemplateVariables.Add("ClubPhoneNumber", club.Salestelephonenumber.Rendered); System.Text.StringBuilder markupBuilder; markupBuilder = new System.Text.StringBuilder(); markupBuilder.Append(club.Addressline1.Rendered); markupBuilder.Append(!String.IsNullOrEmpty(club.Addressline2.Rendered) ? "<br />" + club.Addressline2.Rendered : ""); markupBuilder.Append(!String.IsNullOrEmpty(club.Addressline3.Rendered) ? "<br />" + club.Addressline3.Rendered : ""); markupBuilder.Append(!String.IsNullOrEmpty(club.Addressline4.Rendered) ? "<br />" + club.Addressline4.Rendered : ""); markupBuilder.Append("<br />" + club.Postcode.Rendered); objTemplateVariables.Add("ClubAddress", markupBuilder.ToString()); //Get the facility modules that are to be shown on listing page List<TreatmentModuleItem> treatmentModules = listing.Sharedtreatments.ListItems.ToList().ConvertAll(X => new TreatmentModuleItem(X)); //Chosen Treatment and Brand details string strTreatment = ""; string strHealthAndBeautyBrand = ""; string strTreatmentBrandDetails = ""; strTreatment = drpTreatment.SelectedValue.ToString() != Translate.Text("Select") ? drpTreatment.SelectedValue.ToString() : ""; foreach (TreatmentModuleItem module in treatmentModules) { //find which brand the treatment belows to sharedLanding = new HealthAndBeautyLandingItem(module.InnerItem.Axes.SelectSingleItem(String.Format(@"ancestor-or-self::*[@@tid=""{0}""]", HealthAndBeautyLandingItem.TemplateId))); if (sharedLanding != null) { strHealthAndBeautyBrand = sharedLanding.PageSummary.NavigationTitle.Rendered; strEmailSubject = strEmailSubject.Replace("<SpaName>", strHealthAndBeautyBrand); } break; } if (strTreatment != "" && strHealthAndBeautyBrand != "" && blnIsAppointment) { strTreatmentBrandDetails = strTreatment + " at " + strHealthAndBeautyBrand + ", " + club.Clubname.Rendered; } else if (strHealthAndBeautyBrand != "") { strTreatmentBrandDetails = strHealthAndBeautyBrand + ", " + club.Clubname.Rendered; } else if (strTreatment != "") { strTreatmentBrandDetails = strHealthAndBeautyBrand + ", " + club.Clubname.Rendered; } else { strTreatmentBrandDetails = club.Clubname.Rendered; } objTemplateVariables.Add("TreatmentBrandDetails", strTreatmentBrandDetails); //Chosen Time and Day options string strDay = txtPreferredDay.Value.Trim(); string strTime = drpPreferredTime.SelectedValue.ToString() != Translate.Text("Select") ? drpPreferredTime.SelectedValue.ToString() : ""; string strDayAndTime = ""; if (strDay != "" && strTime != "") { strDayAndTime = strDay + " and " + strTime; } else if (strDay != "") { strDayAndTime = strDay; } objTemplateVariables.Add("PreferredDayAndTime", strDayAndTime); //Parser objParser = new Parser(Server.MapPath(strEmailTemplate), objTemplateVariables); Parser objParser = new Parser(objTemplateVariables); objParser.SetTemplate(EmailTemplate.Emailhtml.Text); string strMessageBody = objParser.Parse(); mm.sharedtools.EmailMessagingService.SendResult objSendResult = new mm.sharedtools.EmailMessagingService.SendResult(); mm.sharedtools.EmailMessagingService.Messaging objMessaging = new mm.sharedtools.EmailMessagingService.Messaging(); string strAttachments = ""; //now call messaging service objSendResult = objMessaging.SendMailSecure(strEmailFromAddress, strEmailToAddress, "", Settings.BccEmailAddress, strEmailSubject, true, strMessageBody, strAttachments); if (objSendResult.Success == true) { blnEmailSent = true; } } catch (Exception ex) { Log.Error(String.Format("Error sending confirmation email {1}: {0}", ex.Message, club.Clubname.Raw), this); mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex); } return blnEmailSent; }
protected void Page_Load(object sender, EventArgs e) { section = Sitecore.Web.WebUtil.GetQueryString("section"); Item[] firstList = currentItem.InnerItem.Axes.SelectItems(String.Format(@"ancestor-or-self::*[@@tid=""{0}"" or @@tid=""{1}""]/child::*", ClassicClubItem.TemplateId, LifeCentreItem.TemplateId)); if (firstList != null) { List<Item> firstLevelList = firstList.ToList(); List<Item> contextAncestorsOrSelf = currentItem.InnerItem.Axes.SelectItems("./ancestor-or-self::*").ToList(); List<PageSummaryItem> firstLevel = firstLevelList.ConvertAll(x => new PageSummaryItem(x)); firstLevel.RemoveAll(x => x.Hidefrommenu.Checked); firstLevel.Last().IsLast = true; //need to figure out the 'active' first level item (the one to highlight) //This can then also be used to build to second level foreach (PageSummaryItem item in firstLevel) { if (SitecoreHelper.ListContainsItem(contextAncestorsOrSelf, item.InnerItem)) { item.IsCurrent = true; currentfirstLevelItem = item; break; } } //Bind the first level items TopElements.DataSource = firstLevel; TopElements.DataBind(); } if (currentfirstLevelItem != null && (currentfirstLevelItem.InnerItem.TemplateID.ToString() != ItemPaths.BlogTemplateId) && (currentfirstLevelItem.InnerItem.TemplateID.ToString() != TimetableDownloadItem.TemplateId) && (currentfirstLevelItem.InnerItem.TemplateID.ToString() != FeedbackItem.TemplateId) ) { //Do not build the second level for blog section. if (currentfirstLevelItem.InnerItem.HasChildren) { bool notBound = true; if (currentfirstLevelItem.InnerItem.TemplateID.ToString() == HealthAndBeautyLandingItem.TemplateId) { //Get treatment listing details ClubHealthAndBeautyListingItem listing = new ClubHealthAndBeautyListingItem(Sitecore.Context.Item); //Get the facility modules that are to be shown on listing page List<TreatmentModuleItem> treatmentModules = listing.Sharedtreatments.ListItems.ToList().ConvertAll(X => new TreatmentModuleItem(X)); HealthAndBeautyLandingItem currentBrand = null; HealthAndBeautyListingItem currentListing = null; List<HealthAndBeautyListingItem> sharedListings = new List<HealthAndBeautyListingItem>(); List<HealthAndBeautyListingItem> clubListings = new List<HealthAndBeautyListingItem>(); List<HealthAndBeautyListingItem> clubListingsAvailable = new List<HealthAndBeautyListingItem>(); foreach (TreatmentModuleItem module in treatmentModules) { //if first item load the shared content if (currentBrand == null) { //find which brand the treatment belongs to Item brand = module.InnerItem.Axes.SelectSingleItem(String.Format(@"ancestor-or-self::*[@@tid=""{0}""]", HealthAndBeautyLandingItem.TemplateId)); if (brand != null) { currentBrand = new HealthAndBeautyLandingItem(brand); sharedListings = currentBrand.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", HealthAndBeautyListingItem.TemplateId)).ToList().ConvertAll(x => new HealthAndBeautyListingItem(x)); } } //check current listing currentListing = new HealthAndBeautyListingItem(module.InnerItem.Axes.SelectSingleItem(String.Format(@"ancestor-or-self::*[@@tid=""{0}""]", HealthAndBeautyListingItem.TemplateId))); if(currentListing != null) { //Add listing to the listings available collection bool blnExist = false; //Check if it exists already foreach (HealthAndBeautyListingItem existingClubListings in clubListingsAvailable) { if(existingClubListings.ID.ToString() == currentListing.ID.ToString()) { blnExist = true; break; } } if(blnExist == false) { //Check that it exists as a listing under the shared brand foreach (HealthAndBeautyListingItem sharedList in sharedListings) { if (sharedList.ID.ToString() == currentListing.ID.ToString()) { clubListingsAvailable.Add(currentListing); } } } } } if (clubListingsAvailable.Count > 1) { HealthAndBeautySecondaryNav(clubListingsAvailable, new PageSummaryItem(currentfirstLevelItem.InnerItem.Children[0]).Url); } notBound = false; } if (notBound) { DataBindSecondaryNav(currentfirstLevelItem.InnerItem, ""); } } } }
protected void Page_Load(object sender, EventArgs e) { //Check if listing is already initialised (i.e. loaded as the default listing page for the landing page) if (listing != null) { //Add datepicker jquery plugin script this.Page.FindControl("ScriptPh").Controls.Add(new LiteralControl(@"<script src=""/virginactive/scripts/jquery-ui-1.8.15.custom.min.js""></script>")); //Register script this.Page.FindControl("ScriptPh").Controls.Add(new LiteralControl(@"<script> $(function(){ $.va_init.functions.addDatepicker(); $.va_init.functions.addTreatmentToDropDown(); }); </script>")); //Get club club = SitecoreHelper.GetCurrentClub(listing.InnerItem); //get the details of the first manager listed for the club (i.e. the manager) List<ManagerItem> staffMembers = null; Item[] mgrItems = club.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", ManagerItem.TemplateId)); if (mgrItems != null) { staffMembers = mgrItems.ToList().ConvertAll(x => new ManagerItem(x)); clubManager = staffMembers.First(); } //Get the facility modules that are to be shown on listing page treatmentModules = listing.Sharedtreatments.ListItems.ToList().ConvertAll(X => new TreatmentModuleItem(X)); foreach (TreatmentModuleItem module in treatmentModules) { //find which brand the treatment belows to sharedLanding = new HealthAndBeautyLandingItem(module.InnerItem.Axes.SelectSingleItem(String.Format(@"ancestor-or-self::*[@@tid=""{0}""]", HealthAndBeautyLandingItem.TemplateId))); sharedListing = new HealthAndBeautyListingItem(module.InnerItem.Axes.SelectSingleItem(String.Format(@"ancestor-or-self::*[@@tid=""{0}""]", HealthAndBeautyListingItem.TemplateId))); break; } if (sharedLanding != null) { string section = Sitecore.Web.WebUtil.GetQueryString("section"); if (!String.IsNullOrEmpty(section)) { //get the correct section listing item from the querystring sharedListing = sharedLanding.InnerItem.Axes.GetDescendant(section); } if (sharedListing != null) { if (listing.Pricelistavailable.Checked == true && listing.Pricelist != null) { downloadPriceListUrl = listing.Pricelist.MediaUrl; downloadPriceList = @"<li><a href=""" + downloadPriceListUrl + @""">" + Translate.Text("Download a price list") + "</a></li>"; } else { PriceList.Visible = false; } //Get list of shared treaments if (sharedListing.InnerItem.HasChildren) { List<TreatmentModuleItem> sharedTreatmentList = sharedListing.InnerItem.Children.ToList().ConvertAll(X => new TreatmentModuleItem(X)); foreach (TreatmentModuleItem sharedTreatmentModule in sharedTreatmentList) { //Check if this treatment has been included for this club foreach(TreatmentModuleItem module in treatmentModules) { if (module.ID.ToString() == sharedTreatmentModule.ID.ToString()) { //Show this treatment treatmentListToShow.Add(module); } } } if (treatmentListToShow.Count > 0) { treatmentListToShow.First().IsFirst = true; TreatmentList.DataSource = treatmentListToShow; TreatmentList.DataBind(); } } } } string val = Translate.Text("Please enter {0}"); rfvName.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a name"))); revName.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a valid name"))); rfvEmail.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("an email address"))); revEmail.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a valid email address"))); rfvPhone.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a phone number"))); revPhone.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a valid phone number"))); //rfvComments.ErrorMessage = String.Format("<p>{0}</p>", String.Format(val, Translate.Text("your comments"))); revEmail.ValidationExpression = Settings.EmailAddressRegularExpression; revPhone.ValidationExpression = Settings.PhoneNumberRegularExpression; revName.ValidationExpression = Settings.NameRegularExpression; if (!Page.IsPostBack) { BindDropDownLists(); } } this.Page.FindControl("ScriptPh").Controls.Add(new LiteralControl(@"<script> $(function(){ $.va_init.functions.setupForms(); }); </script>")); }