Пример #1
0
        internal static void EnsureCommentExists(String commentGuid, out CommentLINQ commentLinq, String message, MinimaServiceLINQDataContext db)
        {
            Func <CommentLINQ, Boolean> commentExists = x => x.CommentGuid == commentGuid;

            commentLinq = db.Comments.SingleOrDefault(commentExists);
            if (commentLinq == null)
            {
                throw new ArgumentException(message);
            }
        }
Пример #2
0
        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);
        }
Пример #3
0
 //- ~EnsureCommentExists -//
 internal static void EnsureCommentExists(String commentGuid, out CommentLINQ commentLinq, MinimaServiceLINQDataContext db)
 {
     EnsureCommentExists(commentGuid, out commentLinq, Message.InvalidCommentGuid, db);
 }