public void RemindRequestServiceTest()
        {
            var request = new RemindRequest()
            {
                Expression = "AddAndDeleteTest",
                Permalink  = "somelink",
                User       = "******"
            };

            remindRequestService.Save(request);
            var all = remindRequestService.GetAll();

            remindRequestService.Delete(all.First(x => x.Expression == "AddAndDeleteTest"));
        }
Beispiel #2
0
        private void Handle(Comment comment)
        {
            try
            {
                comment.SetAsRead();

                if (!ContainsUserMention(comment))
                {
                    return;
                }

                var remindRequests   = new List <RemindRequest>();
                var decodedBody      = WebUtility.HtmlDecode(comment.Body);
                var extractionResult = expressionExtractor.Extract(decodedBody);
                if (!extractionResult.Expressions.Any() && !extractionResult.InvalidExpressions.Any())
                {
                    return;
                }

                foreach (var expression in extractionResult.Expressions)
                {
                    var request = CreateRemindRequest(comment, expression);
                    remindRequestService.Save(request);
                    remindRequests.Add(request);
                }

                var message = CreateReplyMessage(remindRequests, extractionResult.InvalidExpressions);
                if (!string.IsNullOrEmpty(message))
                {
                    comment.Reply(message);
                }
            }
            catch (Exception e)
            {
                Trace.TraceError(e.Message);
            }
        }