public HtmlTemplate Clone() { HtmlTemplate t = new HtmlTemplate(); t.Body = this.Body; t.DisplayName = this.DisplayName; t.From = this.From; t.LastUpdatedUtc = this.LastUpdatedUtc; t.RepeatingSection = this.RepeatingSection; t.StoreId = this.StoreId; t.Subject = this.Subject; t.TemplateType = HtmlTemplateType.Custom; return t; }
public HtmlTemplate Clone() { HtmlTemplate t = new HtmlTemplate(); t.Body = this.Body; t.DisplayName = this.DisplayName; t.From = this.From; t.LastUpdatedUtc = this.LastUpdatedUtc; t.RepeatingSection = this.RepeatingSection; t.StoreId = this.StoreId; t.Subject = this.Subject; t.TemplateType = HtmlTemplateType.Custom; return(t); }
private void CheckForType(HtmlTemplateType checkType, List <HtmlTemplate> existing) { var existCount = existing.Where(y => y.TemplateType == checkType).Count(); if (existCount < 1) { HtmlTemplate standard = GetDefaultTemplate(checkType); if (standard != null) { standard.Id = 0; standard.StoreId = context.CurrentStore.Id; HtmlTemplates.Create(standard); existing.Add(standard); } } }
public HtmlTemplate ReplaceTagsInTemplate(MerchantTribeApplication app, List <IReplaceable> items, List <IReplaceable> repeatingItems) { HtmlTemplate copy = this.Clone(); // Replace Store Defaults foreach (HtmlTemplateTag tag in this.DefaultReplacementTags(app)) { copy.Subject = tag.ReplaceTags(copy.Subject); copy.Body = tag.ReplaceTags(copy.Body); copy.From = tag.ReplaceTags(copy.From); } // Replace Tags in Body and Subject foreach (IReplaceable item in items) { foreach (HtmlTemplateTag tag in item.GetReplaceableTags(app)) { copy.Subject = tag.ReplaceTags(copy.Subject); copy.Body = tag.ReplaceTags(copy.Body); copy.From = tag.ReplaceTags(copy.From); } } // Build Repeating Section StringBuilder sb = new StringBuilder(); foreach (IReplaceable repeatingItem in repeatingItems) { string temp = copy.RepeatingSection; foreach (HtmlTemplateTag tag in repeatingItem.GetReplaceableTags(app)) { temp = tag.ReplaceTags(temp); } sb.Append(temp); } // Copy repeating section to body string allrepeating = sb.ToString(); copy.Body = copy.Body.Replace("[[RepeatingSection]]", allrepeating); return(copy); }
public HtmlTemplate GetHtmlTemplateOrDefault(HtmlTemplateType templateType) { HtmlTemplate existing = HtmlTemplates.FindByStoreAndType(context.CurrentStore.Id, templateType); if (existing == null) { HtmlTemplate standard = GetDefaultTemplate(templateType); if (standard != null) { standard.Id = 0; standard.StoreId = context.CurrentStore.Id; HtmlTemplates.Create(standard); } return(standard); } return(existing); }
private bool Save() { bool result = false; HtmlTemplate e = MTApp.ContentServices.HtmlTemplates.Find(CurrentTemplateId()); if (CurrentTemplateId() == 0) e = new HtmlTemplate(); if (e == null) return false; e.Body = this.BodyField.Text.Trim(); e.DisplayName = this.DisplayNameField.Text.Trim(); e.From = this.FromField.Text.Trim(); e.RepeatingSection = this.RepeatingSectionField.Text.Trim(); e.Subject = this.SubjectField.Text.Trim(); long typeId = 0; long.TryParse(this.lstTemplateType.SelectedValue, out typeId); if (typeId < 0) typeId = 0; e.TemplateType = (HtmlTemplateType)typeId; if (e.Id == 0) { result = MTApp.ContentServices.HtmlTemplates.Create(e); } else { result = MTApp.ContentServices.HtmlTemplates.Update(e); } if (result == true) { // Update bvin field so that next save will call updated instead of create this.BvinField.Value = e.Id.ToString(); } return result; }