This commit is contained in:
2021-06-09 18:43:46 +00:00
parent 04e9d94ece
commit d9e1766210
3 changed files with 57 additions and 49 deletions

View File

@@ -493,7 +493,6 @@ namespace AyaNova.Biz
bool isNew = currentObj == null;
//STANDARD EVENTS FOR ALL OBJECTS
await NotifyEventHelper.ProcessStandardObjectEvents(ayaEvent, proposedObj, ct);
@@ -513,47 +512,54 @@ namespace AyaNova.Biz
//it not completed yet and not overdue already (which could indicate an import or something)
if (r.CompletedDate == null && r.DueDate > DateTime.UtcNow)
{
var userNotifySub = await NotifyEventHelper.EnsureDefaultInAppUserNotificationSubscriptionExists(r.UserId, ct);
NotifySubscription supervisorNotifySub = null;
//Notify user
await NotifyEventHelper.EnsureDefaultInAppUserNotificationSubscriptionExists(r.UserId, ct);
{
var gensubs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.GeneralNotification && z.UserId == r.UserId).ToListAsync();
foreach (var sub in gensubs)
{
var eventNameTranslated = await TranslationBiz.GetTranslationForUserStaticAsync("ReviewOverDue", r.UserId);
NotifyEvent n = new NotifyEvent()
{
EventType = NotifyEventType.GeneralNotification,
UserId = r.UserId,
ObjectId = proposedObj.Id,
AyaType = AyaType.Review,
NotifySubscriptionId = sub.Id,
Name = $"{eventNameTranslated} - {proposedObj.Name}",
EventDate = r.DueDate
};
await ct.NotifyEvent.AddAsync(n);
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
}
if (gensubs.Count > 0)
await ct.SaveChangesAsync();
}
//Notify supervisor
if (r.UserId != r.AssignedByUserId)
{
supervisorNotifySub = await NotifyEventHelper.EnsureDefaultInAppUserNotificationSubscriptionExists(r.AssignedByUserId, ct);
}
{
var eventNameTranslated = await TranslationBiz.GetTranslationForUserStaticAsync("ReviewOverDue", r.UserId);
NotifyEvent n = new NotifyEvent()
await NotifyEventHelper.EnsureDefaultInAppUserNotificationSubscriptionExists(r.AssignedByUserId, ct);
var gensubs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.GeneralNotification && z.UserId == r.AssignedByUserId).ToListAsync();
foreach (var sub in gensubs)
{
EventType = NotifyEventType.GeneralNotification,
UserId = r.UserId,
ObjectId = proposedObj.Id,
AyaType = AyaType.Review,
NotifySubscriptionId = userNotifySub.Id,
Name = $"{eventNameTranslated} - {proposedObj.Name}",
EventDate = r.DueDate
};
await ct.NotifyEvent.AddAsync(n);
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
var eventNameTranslated = await TranslationBiz.GetTranslationForUserStaticAsync("ReviewOverDue", r.AssignedByUserId);
NotifyEvent n = new NotifyEvent()
{
EventType = NotifyEventType.GeneralNotification,
UserId = r.AssignedByUserId,
ObjectId = proposedObj.Id,
AyaType = AyaType.Review,
NotifySubscriptionId = sub.Id,
Name = $"{eventNameTranslated} - {proposedObj.Name}",
EventDate = r.DueDate
};
await ct.NotifyEvent.AddAsync(n);
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
}
if (gensubs.Count > 0)
await ct.SaveChangesAsync();
}
if (supervisorNotifySub != null)
{
var eventNameTranslated = await TranslationBiz.GetTranslationForUserStaticAsync("ReviewOverDue", r.AssignedByUserId);
NotifyEvent n = new NotifyEvent()
{
EventType = NotifyEventType.GeneralNotification,
UserId = r.AssignedByUserId,
ObjectId = proposedObj.Id,
AyaType = AyaType.Review,
NotifySubscriptionId = supervisorNotifySub.Id,
Name = $"{eventNameTranslated} - {proposedObj.Name}",
EventDate = r.DueDate
};
await ct.NotifyEvent.AddAsync(n);
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
}
await ct.SaveChangesAsync();
}
}//overdue event
}//custom events for created / modified