case 4240

This commit is contained in:
2022-11-10 20:14:11 +00:00
parent 82242161ed
commit c1ac0c5ed8
2 changed files with 88 additions and 79 deletions

View File

@@ -1130,6 +1130,8 @@ namespace AyaNova.Biz
//CREATE
//
internal async Task<QuoteState> StateCreateAsync(QuoteState newObject)
{
using (var transaction = await ct.Database.BeginTransactionAsync())//case 4240 wrapped in transaction because header is updated as well as states collection so both need to be in sync
{
await StatePreliminaryValidateCanAddAsync(newObject);
if (HasErrors)
@@ -1168,10 +1170,12 @@ namespace AyaNova.Biz
newObject.NewQuoteConcurrency = quote.Concurrency;
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, AyaType.QuoteStatus, AyaEvent.Created), ct);
await transaction.CommitAsync();
await StateHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
return newObject;
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
// GET

View File

@@ -1711,6 +1711,8 @@ namespace AyaNova.Biz
//CREATE
//
internal async Task<WorkOrderState> StateCreateAsync(WorkOrderState newObject)
{
using (var transaction = await ct.Database.BeginTransactionAsync())//case 4240 wrapped in transaction because workorder header is updated as well as states collection so both need to be in sync
{
//first validate if this is even a possibility before getting into the further validation
//for roles can select, can remove etc
@@ -1744,6 +1746,8 @@ namespace AyaNova.Biz
}
//Seems legit, we'll allow it
await ct.WorkOrderState.AddAsync(newObject);
//Set duration to completed in workorder header
//Clear it if set and not completed state
@@ -1756,12 +1760,13 @@ namespace AyaNova.Biz
wo.LastStatusId = newObject.WorkOrderStatusId;
await ct.SaveChangesAsync();
newObject.NewWOConcurrency = wo.Concurrency;
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, AyaType.WorkOrderStatus, AyaEvent.Created), ct);
await transaction.CommitAsync();
await StateHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
return newObject;
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
// GET