public String PostNewComment(String blogEntryGuid, String text, String author, String email, String website, DateTime dateTime, String emailBodyTemplate, String emailSubject) { String commentGuid = String.Empty; String blogEntryTitle = String.Empty; using (DataContext db = new DataContext(ServiceConfiguration.ConnectionString)) { //+ validate BlogEntryLINQ blogEntryLinq; Validator.EnsureBlogEntryExists(blogEntryGuid, out blogEntryLinq, db); //+ CommentLINQ commentLinq = new CommentLINQ(); commentLinq.CommentEmail = email; commentLinq.CommentAuthor = author; commentLinq.CommentText = text; if (website.ToLower().StartsWith("http://") || website.ToLower().StartsWith("https://")) { commentLinq.CommentWebsite = website; } commentLinq.CommentPostDate = dateTime; commentLinq.CommentModerated = true; commentLinq.BlogEntryId = blogEntryLinq.BlogEntryId; commentLinq.CommentGuid = Themelia.GuidCreator.GetNewGuid(); //+ db.Comments.InsertOnSubmit(commentLinq); db.SubmitChanges(); //+ commentGuid = commentLinq.CommentGuid; //+ blogEntryTitle = blogEntryLinq.BlogEntryTitle; } //+ email Themelia.Map map = new Themelia.Map(); map.Add("BlogEntryTitle", blogEntryTitle); map.Add("CommentGuid", commentGuid); String body = new Themelia.Template(emailBodyTemplate).Interpolate(map); //+ this could be sent from the person, but those e-mails will more than likely be caught by a spam filter. Emailer.Send(MailConfiguration.GeneralFromEmailAddress, MailConfiguration.GeneralToEmailAddress, emailSubject, body, MailOptions.IsHtml); //+ return(commentGuid); }
//+ //- @InstantiateIn -// public void InstantiateIn(System.Web.UI.Control container) { System.Web.UI.WebControls.PlaceHolder pane = new System.Web.UI.WebControls.PlaceHolder(); switch (type) { case ListItemType.Item: pane.DataBinding += new EventHandler(delegate(Object sender, System.EventArgs ea) { RepeaterItem item = (RepeaterItem)pane.NamingContainer; //+ System.Web.UI.WebControls.Literal dtHeader = new System.Web.UI.WebControls.Literal(); dtHeader.Text = "<dl class=\"index-section-list\"><dt>"; pane.Controls.Add(dtHeader); //+ System.Web.UI.WebControls.Literal image = new System.Web.UI.WebControls.Literal(); Themelia.Template template = new Themelia.Template(Themelia.Template.Common.Image); Themelia.Map map = new Themelia.Map(); BlogEntryType blogEntryType = FindBlogEntryType((String)DataBinder.Eval(item.DataItem, "TypeGuid")); if (blogEntryType != null && !String.IsNullOrEmpty(blogEntryType.Extra)) { map.Add("Source", blogEntryType.Extra); map.Add("Text", blogEntryType.Name); image.Text = template.Interpolate(map); pane.Controls.Add(image); } //+ System.Web.UI.WebControls.Literal dtddConnection = new System.Web.UI.WebControls.Literal(); dtddConnection.Text = "</dt><dd>"; pane.Controls.Add(dtddConnection); //+ System.Web.UI.WebControls.Literal link = new System.Web.UI.WebControls.Literal(); template = new Themelia.Template(Themelia.Template.Common.Link); map = new Themelia.Map(); map.Add("Link", (String)DataBinder.Eval(item.DataItem, "Url")); map.Add("Text", (String)DataBinder.Eval(item.DataItem, "Title")); link.Text = template.Interpolate(map); pane.Controls.Add(link); //+ List <Minima.Service.Label> labelList = (List <Minima.Service.Label>)DataBinder.Eval(item.DataItem, "LabelList"); if (labelList != null && labelList.Count > 0) { Repeater rptLabel = new Repeater(); rptLabel.DataSource = labelList.Select(label => new { Title = label.Title, Url = LabelHelper.GetLabelUrl(label) }); rptLabel.HeaderTemplate = new IndexLabelListTemplate(ListItemType.Header); rptLabel.ItemTemplate = new IndexLabelListTemplate(ListItemType.Item); rptLabel.FooterTemplate = new IndexLabelListTemplate(ListItemType.Footer); pane.Controls.Add(rptLabel); } //+ System.Web.UI.WebControls.Literal ddFooter = new System.Web.UI.WebControls.Literal(); ddFooter.Text = "</dd></dl>"; pane.Controls.Add(ddFooter); }); break; } container.Controls.Add(pane); }