Esempio n. 1
0
        public CommandResult Execute(NewCommentCommand command)
        {
            if (_spamShield.IsSpam(command.SpamShield))
            {
                return(new CommandResult("You are a spam!"));
            }

            var comment = new BlogComment
            {
                Id          = command.Id,
                Email       = command.Email,
                NickName    = command.NickName,
                Content     = command.Content,
                IPAddress   = command.IPAddress,
                PostId      = command.PostId,
                SiteUrl     = command.SiteUrl,
                CreatedTime = DateTime.UtcNow
            };

            using (var db = new LiteDatabase(_dbConfig.DbPath))
            {
                var blogCommentCol = db.GetCollection <BlogComment>(DBTableNames.BlogComments);
                blogCommentCol.Insert(comment);

                return(CommandResult.SuccessResult);
            }
        }
Esempio n. 2
0
        public CommandResult Execute(NewCommentCommand command)
        {
            if (_spamShield.IsSpam(command.SpamShield))
            {
                return(new CommandResult("You are a spam!"));
            }

            var comment = new BlogComment
            {
                Id          = command.Id,
                Email       = command.Email,
                NickName    = command.NickName,
                Content     = command.Content,
                IPAddress   = command.IPAddress,
                PostId      = command.PostId,
                SiteUrl     = command.SiteUrl,
                CreatedTime = DateTime.UtcNow
            };

            var result = _db.Insert(DBTableNames.BlogComments, comment);

            return(CommandResult.SuccessResult);
        }