case 4628 - deleting a work order made from a service request reopens the request
The request's link to the work order item blocked the delete with a database error (500). Deleting the item now unlinks any request accepted into it and sets it back to Open, in the same transaction, with a history entry and no notification. Service request manual page and changelog. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2423,6 +2423,21 @@ namespace AyaNova.Biz
|
||||
if (!await OutsideServiceDeleteAsync(ItemId, transaction))
|
||||
return false;
|
||||
|
||||
//case 4628: a customer service request accepted into this item goes back to Open, unlinked (its link blocked the
|
||||
//delete with a raw database error); no notification, an entry in the request's history
|
||||
var acceptedRequests = await ct.CustomerServiceRequest.Where(z => z.WorkOrderItemId == id).ToListAsync();
|
||||
foreach (var csr in acceptedRequests)
|
||||
{
|
||||
csr.WorkOrderItemId = null;
|
||||
csr.Status = CustomerServiceRequestStatus.Open;
|
||||
}
|
||||
if (acceptedRequests.Count > 0)
|
||||
{
|
||||
await ct.SaveChangesAsync();
|
||||
foreach (var csr in acceptedRequests)
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, csr.Id, AyaType.CustomerServiceRequest, AyaEvent.Modified), ct);
|
||||
}
|
||||
|
||||
ct.WorkOrderItem.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user