This commit is contained in:
2022-03-07 20:08:45 +00:00
parent cee78d5c3f
commit 73f8dbc3dc
18 changed files with 125 additions and 28 deletions

View File

@@ -1249,6 +1249,7 @@ namespace AyaNova.Biz
{
//# STATUS CHANGE (create new status)
{
//PERSONAL SUBSCCRIPTION
//Conditions: must match specific status id value and also tags below
//delivery is immediate so no need to remove old ones of this kind
var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.QuoteStatusChange && z.IdValue == oProposed.QuoteStatusId).ToListAsync();
@@ -1276,6 +1277,44 @@ namespace AyaNova.Biz
}
}//quote status change event
{
//PROXY CUSTOMER NOTIFICATION SUBSCRIPTION HANDLING
//can this customer even be delivered to?
var custInfo = await ct.Customer.AsNoTracking().Where(x => x.Id == QuoteInfo.CustomerId).Select(x => new { x.Active, x.Tags, x.EmailAddress }).FirstOrDefaultAsync();
if (custInfo != null && custInfo.Active && !string.IsNullOrWhiteSpace(custInfo.EmailAddress))
{
//Conditions: must match specific status id value and also tags below
//delivery is immediate so no need to remove old ones of this kind
//note order by id ascending so that only the oldest notification "wins" as per docs in case of overlap to same customer
var subs = await ct.CustomerNotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.QuoteStatusChange && z.IdValue == oProposed.QuoteStatusId).OrderBy(z=>z.Id).ToListAsync();
foreach (var sub in subs)
{
//Object tags must match and Customer tags must match
if (NotifyEventHelper.ObjectHasAllSubscriptionTags(QuoteInfo.Tags, sub.Tags) && NotifyEventHelper.ObjectHasAllSubscriptionTags(custInfo.Tags, sub.CustomerTags))
{
NotifyEvent n = new NotifyEvent()
{
EventType = NotifyEventType.QuoteStatusChange,
UserId = sub.UserId,
AyaType = AyaType.Quote,
ObjectId = oProposed.QuoteId,
NotifySubscriptionId = sub.Id,
Name = $"{QuoteInfo.Serial.ToString()} - {qos.Name}"
};
await ct.NotifyEvent.AddAsync(n);
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
await ct.SaveChangesAsync();
break;//we have a match no need to process any further subs for this event
}
}
}
}//quote status change event
//# STATUS AGE
{
//QuoteStatusAge = 29,//* Quote STATUS unchanged for set time (stuck in state), conditional on: Duration (how long stuck), exact status selected IdValue, Tags. Advance notice can NOT be set
@@ -4172,7 +4211,7 @@ namespace AyaNova.Biz
return;
}
if (!isNew && UserIsRestrictedType)
if (!isNew && UserIsRestrictedType)
{
//Existing record so just make sure they haven't changed the not changeable fields from the db version
//* Tasks: view and edit existing tasks, set completion type and date only, no add or remove or changing other fields