public ContentItem NewEntry(ContactFormEntry entry) { var contentItem = _services.ContentManager.New("ContactFormEntry"); var commonPart = contentItem.As<CommonPart>(); var titlePart = contentItem.As<TitlePart>(); var bodyPart = contentItem.As<BodyPart>(); var contactFormEntryPart = contentItem.As<ContactFormEntryPart>(); commonPart.CreatedUtc = entry.CreatedUtc; titlePart.Title = entry.Subject; bodyPart.Text = entry.MessageBody; contactFormEntryPart.SenderName = entry.Name; contactFormEntryPart.SenderEmail = entry.Email; return contentItem; }
public ContentItem StoreEntry(ContactFormEntry entry) { foreach (var filter in _filters) { filter.Process(entry); } var contentItem = NewEntry(entry); 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("Your message has been received. Thanks for contacting us!")); return contentItem; }