This commit is contained in:
2021-02-16 17:49:16 +00:00
parent 8ba9b393ba
commit ea356ba764

View File

@@ -411,26 +411,38 @@ namespace AyaNova.Biz
//CREATED / MODIFIED
if (ayaEvent == AyaEvent.Created || ayaEvent == AyaEvent.Modified)
{
var p = (PurchaseOrder)proposedObj;
var c = (PurchaseOrder)currentObj;
//PartRequestReceived event?
{
var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.PartRequestReceived).ToListAsync();
if (subs.Count > 0)
//get a list of all items with part requests and received inventory
var proposedRequestItems = p.Items.Where(z => z.WorkorderItemPartRequestId != null && z.QuantityReceived != 0);
//are there any potential notify items?
if (proposedRequestItems.Count() > 0)
{
var p = (PurchaseOrder)proposedObj;
var c = (PurchaseOrder)currentObj;
List<NotifySubscription> subs = null;
//are any of them new, or a change from before?
// var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.PartRequestReceived).ToListAsync();
//Look for new receipts of requested parts
foreach (var proposedpoitem in p.Items.Where(z => z.WorkorderItemPartRequestId != null && z.QuantityReceived != 0))
foreach (var proposedRequestItem in proposedRequestItems)
{
//Get the matching item from db collection
var currentpoitem = c.Items.FirstOrDefault(z => z.Id == proposedpoitem.Id);
var currentMatchingRequestItem = c.Items.FirstOrDefault(z => z.Id == proposedRequestItem.Id);
//if it doesn't exist or received less than the proposed item then we have actionable notification
if (currentpoitem == null || currentpoitem.QuantityReceived < proposedpoitem.QuantityReceived)
if (currentMatchingRequestItem == null || currentMatchingRequestItem.QuantityReceived < proposedRequestItem.QuantityReceived)
{
//is there a subscriber for this user id and event?
var sub = await ct.NotifySubscription.FirstOrDefaultAsync(z => z.EventType == NotifyEventType.PartRequestReceived && z.UserId == proposedRequestItem.PartRequestedById);
}
}
}
}