using System; using System.ComponentModel.DataAnnotations.Schema; namespace Oqtane.Models { /// /// Notification for a User - usually meant to be sent as an E-Mail. /// public class Notification : IDeletable { /// /// Internal ID /// public int NotificationId { get; set; } /// /// Reference to the on which the Notification was created. /// public int SiteId { get; set; } /// /// Creator ID /// public int? FromUserId { get; set; } /// /// Nice Name of the Creator /// public string FromDisplayName { get; set; } /// /// Creator E-Mail /// public string FromEmail { get; set; } /// /// Recipient ID - nullable, as Recipient could be someone that's not a user. /// public int? ToUserId { get; set; } /// /// Recipient Nice-Name. /// public string ToDisplayName { get; set; } /// /// Recipient Mail /// public string ToEmail { get; set; } /// /// Reference to an optional Parent - in case it's a kind of thread with reply-messages. /// public int? ParentId { get; set; } /// /// Message Subject. /// public string Subject { get; set; } /// /// Body / Contents of this Notification /// public string Body { get; set; } /// /// When the notification was created. /// public DateTime CreatedOn { get; set; } /// /// If it has been delivered. See also . /// public bool IsDelivered { get; set; } /// /// When the Notification was sent/delivered. /// public DateTime? DeliveredOn { get; set; } #region IDeletable /// public string DeletedBy { get; set; } /// public DateTime? DeletedOn { get; set; } /// public bool IsDeleted { get; set; } #endregion /// /// When the Notification _should_ be sent. See also /// public DateTime? SendOn { get; set; } public Notification() {} public Notification(int siteId, User from, User to, string subject, string body, int? parentId) { SiteId = siteId; if (from != null) { FromUserId = from.UserId; FromDisplayName = from.DisplayName; FromEmail = from.Email; } if (to != null) { ToUserId = to.UserId; ToDisplayName = to.DisplayName; ToEmail = to.Email; } Subject = subject; Body = body; ParentId = parentId; CreatedOn = DateTime.UtcNow; IsDelivered = false; DeliveredOn = null; SendOn = DateTime.UtcNow; } public Notification(int siteId, string fromDisplayName, string fromEmail, string toDisplayName, string toEmail, string subject, string body) { SiteId = siteId; FromUserId = null; FromDisplayName = fromDisplayName; FromEmail = fromEmail; ToUserId = null; ToDisplayName = toDisplayName; ToEmail = toEmail; Subject = subject; Body = body; ParentId = null; CreatedOn = DateTime.UtcNow; IsDelivered = false; DeliveredOn = null; SendOn = DateTime.UtcNow; } } }