Implemented reminder imminent notification type
This commit is contained in:
@@ -308,7 +308,7 @@ namespace AyaNova.Biz
|
||||
|
||||
//populate viz fields from provided object
|
||||
private async Task PopulateVizFields(Reminder o)
|
||||
{
|
||||
{
|
||||
if (!vc.Has("user", o.UserId))
|
||||
vc.Add(await ct.User.AsNoTracking().Where(x => x.Id == o.UserId).Select(x => x.Name).FirstOrDefaultAsync(), "user", o.UserId);
|
||||
o.UserViz = vc.Get("user", o.UserId);
|
||||
@@ -453,14 +453,58 @@ namespace AyaNova.Biz
|
||||
|
||||
bool isNew = currentObj == null;
|
||||
|
||||
Reminder o = (Reminder)proposedObj;
|
||||
|
||||
//STANDARD EVENTS FOR ALL OBJECTS
|
||||
await NotifyEventHelper.ProcessStandardObjectEvents(ayaEvent, proposedObj, ct);
|
||||
|
||||
//SPECIFIC EVENTS FOR THIS OBJECT
|
||||
|
||||
}//end of process notifications
|
||||
//## DELETED EVENTS
|
||||
|
||||
//any event added below needs to be removed, so
|
||||
//just blanket remove any event for this object of eventtype that would be added below here
|
||||
//do it regardless any time there's an update and then
|
||||
//let this code below handle the refreshing addition that could have changes
|
||||
await NotifyEventHelper.ClearPriorEventsForObject(ct, AyaType.Reminder, o.Id, NotifyEventType.ReminderImminent);
|
||||
|
||||
//## CREATED / MODIFIED EVENTS
|
||||
if (ayaEvent == AyaEvent.Created || ayaEvent == AyaEvent.Modified)
|
||||
{
|
||||
//# REMINDER IMMINENT
|
||||
{
|
||||
|
||||
//notify users (time delayed)
|
||||
var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.ReminderImminent).ToListAsync();
|
||||
foreach (var sub in subs)
|
||||
{
|
||||
//not for inactive users
|
||||
if (!await UserBiz.UserIsActive(sub.UserId)) continue;
|
||||
|
||||
//Tag match? (will be true if no sub tags so always safe to call this)
|
||||
if (NotifyEventHelper.ObjectHasAllSubscriptionTags(o.Tags, sub.Tags))
|
||||
{
|
||||
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.ReminderImminent,
|
||||
UserId = sub.UserId,
|
||||
AyaType = o.AyaType,
|
||||
ObjectId = o.Id,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
Name = o.Name,
|
||||
EventDate = o.StartDate
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
}//warranty expiry event
|
||||
|
||||
}//end of process notifications
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user