using System; using System.Collections.Generic; using AyaNova.Biz; using System.ComponentModel.DataAnnotations; using Newtonsoft.Json; namespace AyaNova.Models { //NOTE: Any non required field (nullable in DB) sb nullable here, i.e. decimal? not decimal, //otherwise the server will call it an invalid record if the field isn't sent from client //This class holds events that occur in the database for delivery to users //it's the result of an event happening, not the subscription which is seperate and decides who gets what //when an object is modified it may create a NotifyEvent record if anyone subscribes to that event //it will create one of these for every user with that subscription //which will then be delivered as a notification later when the corejobnotify job runs if it's deliverable public class NotifyEvent { public long Id { get; set; } public uint Concurrency { get; set; } [Required] public DateTime Created { get; set; } public AyaType AyaType { get; set; } public long ObjectId { get; set; } [Required] public string Name { get; set; }//object name or closest equivalent for display [Required] public NotifyEventType EventType { get; set; } [Required] public long UserId { get; set; } [Required] public long NotifySubscriptionId { get; set; }//source subscription that triggered this event to be created public decimal DecValue { get; set; } //date of the event actually occuring, e.g. WarrantyExpiry date. Compared with subscription to determine if deliverable or not public DateTime EventDate { get; set; } public string Message { get; set; } public NotifyEvent() { Created = EventDate = DateTime.UtcNow; // IdValue = 0; DecValue = 0; AyaType = AyaType.NoType; ObjectId = 0; Name = string.Empty; } public override string ToString() { return JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.None); } //linked entity // public NotifySubscription NotifySubscription { get; set; } // public User User { get; set; } }//eoc }//eons