Пример #1
0
        public ContentItem StoreEntry(ContactFormEntry entry)
        {

            foreach (var filter in _filters)
            {
                filter.Process(entry);
            }

            var contentItem = NewEntry(entry);
            var test = contentItem.Id;

            var entryCreatingContext = new ContactFormCreatingContext
            {
                ContactFormEntry = contentItem
            };

            _contactFormEventHandler.ContactFormEntryCreating(entryCreatingContext);

            if (entryCreatingContext.Cancel)
                return null;

            _services.ContentManager.Create(contentItem);

            var entryCreatedContext = new ContactFormCreatedContext
            {
                ContactFormEntry = contentItem
            };

            _contactFormEventHandler.ContactFormEntryCreated(entryCreatedContext);

            _services.Notifier.Information(T("Uw bericht is ontvangen. Dank u voor de reactie!"));
            return contentItem;
        }
        public void ContactFormEntryCreating(ContactFormCreatingContext context)
        {
            var text = context.ContactFormEntry.As<BodyPart>().Text;
            var spamTerms = new[] { "viagra", "opportunity", "win!", "win", "$$$", "Lose weight", "Extra income", "Money making", "Earn $", "Save $" };

            if (!spamTerms.Any(text.Contains))
            {
                _notifier.Information(T("Bericht geaccepteerd"));
                return;
            }

            context.Cancel = true;
            _notifier.Warning(T("Uw bericht is als spam beoordeeld en is daarom niet verstuurd."));
        }