From 7c033a6e84bd15e9dc4c0aba057b2b81a61e93a5 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 5 Aug 2021 22:52:47 +0000 Subject: [PATCH] --- server/AyaNova/biz/ContractBiz.cs | 2 +- server/AyaNova/biz/CustomerBiz.cs | 2 +- server/AyaNova/biz/CustomerNoteBiz.cs | 2 +- .../AyaNova/biz/CustomerServiceRequestBiz.cs | 2 +- server/AyaNova/biz/HeadOfficeBiz.cs | 2 +- server/AyaNova/biz/LoanUnitBiz.cs | 2 +- server/AyaNova/biz/MemoBiz.cs | 2 +- server/AyaNova/biz/NotifySubscriptionBiz.cs | 2 +- server/AyaNova/biz/PMBiz.cs | 22 +- server/AyaNova/biz/PartAssemblyBiz.cs | 2 +- server/AyaNova/biz/PartBiz.cs | 2 +- server/AyaNova/biz/PartInventoryBiz.cs | 4 +- server/AyaNova/biz/PartWarehouseBiz.cs | 2 +- server/AyaNova/biz/ProjectBiz.cs | 2 +- server/AyaNova/biz/PurchaseOrderBiz.cs | 2 +- server/AyaNova/biz/QuoteBiz.cs | 24 +- server/AyaNova/biz/QuoteStatusBiz.cs | 2 +- server/AyaNova/biz/ReminderBiz.cs | 2 +- server/AyaNova/biz/ReportBiz.cs | 2 +- server/AyaNova/biz/ReviewBiz.cs | 2 +- server/AyaNova/biz/ServiceRateBiz.cs | 2 +- server/AyaNova/biz/TaskGroupBiz.cs | 2 +- server/AyaNova/biz/TaxCodeBiz.cs | 2 +- server/AyaNova/biz/TravelRateBiz.cs | 2 +- server/AyaNova/biz/UnitBiz.cs | 2 +- server/AyaNova/biz/UnitModelBiz.cs | 2 +- server/AyaNova/biz/UserBiz.cs | 2 +- server/AyaNova/biz/VendorBiz.cs | 2 +- server/AyaNova/biz/WidgetBiz.cs | 2 +- server/AyaNova/biz/WorkOrderBiz.cs | 621 ++---------------- .../AyaNova/biz/WorkOrderItemPriorityBiz.cs | 2 +- server/AyaNova/biz/WorkOrderItemStatusBiz.cs | 2 +- server/AyaNova/biz/WorkOrderStatusBiz.cs | 2 +- 33 files changed, 127 insertions(+), 602 deletions(-) diff --git a/server/AyaNova/biz/ContractBiz.cs b/server/AyaNova/biz/ContractBiz.cs index ee262bcd..a5c79e35 100644 --- a/server/AyaNova/biz/ContractBiz.cs +++ b/server/AyaNova/biz/ContractBiz.cs @@ -250,7 +250,7 @@ MULTIPLE discount / markup ITEMS } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/CustomerBiz.cs b/server/AyaNova/biz/CustomerBiz.cs index 4bf0b052..f63af520 100644 --- a/server/AyaNova/biz/CustomerBiz.cs +++ b/server/AyaNova/biz/CustomerBiz.cs @@ -210,7 +210,7 @@ namespace AyaNova.Biz { //NOTE: no need to rollback the transaction, it will auto-rollback if not committed and it is disposed when it goes out of scope either way - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/CustomerNoteBiz.cs b/server/AyaNova/biz/CustomerNoteBiz.cs index f3147d1d..7359b3a6 100644 --- a/server/AyaNova/biz/CustomerNoteBiz.cs +++ b/server/AyaNova/biz/CustomerNoteBiz.cs @@ -145,7 +145,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } diff --git a/server/AyaNova/biz/CustomerServiceRequestBiz.cs b/server/AyaNova/biz/CustomerServiceRequestBiz.cs index b0bff845..5bd4cc5b 100644 --- a/server/AyaNova/biz/CustomerServiceRequestBiz.cs +++ b/server/AyaNova/biz/CustomerServiceRequestBiz.cs @@ -173,7 +173,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/HeadOfficeBiz.cs b/server/AyaNova/biz/HeadOfficeBiz.cs index d2a48d17..5a035047 100644 --- a/server/AyaNova/biz/HeadOfficeBiz.cs +++ b/server/AyaNova/biz/HeadOfficeBiz.cs @@ -194,7 +194,7 @@ namespace AyaNova.Biz { //NOTE: no need to rollback the transaction, it will auto-rollback if not committed and it is disposed when it goes out of scope either way - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/LoanUnitBiz.cs b/server/AyaNova/biz/LoanUnitBiz.cs index f3b99ef4..afe9662e 100644 --- a/server/AyaNova/biz/LoanUnitBiz.cs +++ b/server/AyaNova/biz/LoanUnitBiz.cs @@ -178,7 +178,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/MemoBiz.cs b/server/AyaNova/biz/MemoBiz.cs index 8875ba59..1d073ac7 100644 --- a/server/AyaNova/biz/MemoBiz.cs +++ b/server/AyaNova/biz/MemoBiz.cs @@ -164,7 +164,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/NotifySubscriptionBiz.cs b/server/AyaNova/biz/NotifySubscriptionBiz.cs index 19ddf750..005ac765 100644 --- a/server/AyaNova/biz/NotifySubscriptionBiz.cs +++ b/server/AyaNova/biz/NotifySubscriptionBiz.cs @@ -164,7 +164,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/PMBiz.cs b/server/AyaNova/biz/PMBiz.cs index 01cc59d2..f06a6240 100644 --- a/server/AyaNova/biz/PMBiz.cs +++ b/server/AyaNova/biz/PMBiz.cs @@ -367,7 +367,7 @@ namespace AyaNova.Biz catch { //NOTE: no need to rollback the transaction, it will auto-rollback if not committed and it is disposed when it goes out of scope either way - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } @@ -1265,7 +1265,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; @@ -1539,7 +1539,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; @@ -1889,7 +1889,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; @@ -2271,7 +2271,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; @@ -2667,7 +2667,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; @@ -3004,7 +3004,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; @@ -3417,7 +3417,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; @@ -3657,7 +3657,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; @@ -3934,7 +3934,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; @@ -4301,7 +4301,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/PartAssemblyBiz.cs b/server/AyaNova/biz/PartAssemblyBiz.cs index 13ff4887..172f8c1c 100644 --- a/server/AyaNova/biz/PartAssemblyBiz.cs +++ b/server/AyaNova/biz/PartAssemblyBiz.cs @@ -201,7 +201,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/PartBiz.cs b/server/AyaNova/biz/PartBiz.cs index b48b1fc1..b7768c39 100644 --- a/server/AyaNova/biz/PartBiz.cs +++ b/server/AyaNova/biz/PartBiz.cs @@ -178,7 +178,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/PartInventoryBiz.cs b/server/AyaNova/biz/PartInventoryBiz.cs index a22029e4..0cf559cc 100644 --- a/server/AyaNova/biz/PartInventoryBiz.cs +++ b/server/AyaNova/biz/PartInventoryBiz.cs @@ -82,7 +82,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } } @@ -132,7 +132,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } diff --git a/server/AyaNova/biz/PartWarehouseBiz.cs b/server/AyaNova/biz/PartWarehouseBiz.cs index 1a29898a..dfae8e76 100644 --- a/server/AyaNova/biz/PartWarehouseBiz.cs +++ b/server/AyaNova/biz/PartWarehouseBiz.cs @@ -176,7 +176,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/ProjectBiz.cs b/server/AyaNova/biz/ProjectBiz.cs index 869ef56e..d0a004a2 100644 --- a/server/AyaNova/biz/ProjectBiz.cs +++ b/server/AyaNova/biz/ProjectBiz.cs @@ -176,7 +176,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/PurchaseOrderBiz.cs b/server/AyaNova/biz/PurchaseOrderBiz.cs index 64a68037..554dae8c 100644 --- a/server/AyaNova/biz/PurchaseOrderBiz.cs +++ b/server/AyaNova/biz/PurchaseOrderBiz.cs @@ -351,7 +351,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/QuoteBiz.cs b/server/AyaNova/biz/QuoteBiz.cs index 1228a94a..7e0aad58 100644 --- a/server/AyaNova/biz/QuoteBiz.cs +++ b/server/AyaNova/biz/QuoteBiz.cs @@ -379,7 +379,7 @@ namespace AyaNova.Biz catch { //NOTE: no need to rollback the transaction, it will auto-rollback if not committed and it is disposed when it goes out of scope either way - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } @@ -1043,7 +1043,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; @@ -1478,7 +1478,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; @@ -1762,7 +1762,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; @@ -2132,7 +2132,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; @@ -2528,7 +2528,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; @@ -2933,7 +2933,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; @@ -3278,7 +3278,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; @@ -3708,7 +3708,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; @@ -3961,7 +3961,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; @@ -4246,7 +4246,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; @@ -4632,7 +4632,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/QuoteStatusBiz.cs b/server/AyaNova/biz/QuoteStatusBiz.cs index 7a14e568..629c6635 100644 --- a/server/AyaNova/biz/QuoteStatusBiz.cs +++ b/server/AyaNova/biz/QuoteStatusBiz.cs @@ -129,7 +129,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/ReminderBiz.cs b/server/AyaNova/biz/ReminderBiz.cs index ba66bbff..32a742df 100644 --- a/server/AyaNova/biz/ReminderBiz.cs +++ b/server/AyaNova/biz/ReminderBiz.cs @@ -178,7 +178,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/ReportBiz.cs b/server/AyaNova/biz/ReportBiz.cs index fb1ac3db..6e0ec21a 100644 --- a/server/AyaNova/biz/ReportBiz.cs +++ b/server/AyaNova/biz/ReportBiz.cs @@ -228,7 +228,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/ReviewBiz.cs b/server/AyaNova/biz/ReviewBiz.cs index 182c1966..f258e3ce 100644 --- a/server/AyaNova/biz/ReviewBiz.cs +++ b/server/AyaNova/biz/ReviewBiz.cs @@ -178,7 +178,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/ServiceRateBiz.cs b/server/AyaNova/biz/ServiceRateBiz.cs index 4917a443..399a74dd 100644 --- a/server/AyaNova/biz/ServiceRateBiz.cs +++ b/server/AyaNova/biz/ServiceRateBiz.cs @@ -178,7 +178,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/TaskGroupBiz.cs b/server/AyaNova/biz/TaskGroupBiz.cs index 7984e993..827f53fa 100644 --- a/server/AyaNova/biz/TaskGroupBiz.cs +++ b/server/AyaNova/biz/TaskGroupBiz.cs @@ -185,7 +185,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/TaxCodeBiz.cs b/server/AyaNova/biz/TaxCodeBiz.cs index bbe16114..3579f6c6 100644 --- a/server/AyaNova/biz/TaxCodeBiz.cs +++ b/server/AyaNova/biz/TaxCodeBiz.cs @@ -178,7 +178,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/TravelRateBiz.cs b/server/AyaNova/biz/TravelRateBiz.cs index 6f16d1ae..6c8e1961 100644 --- a/server/AyaNova/biz/TravelRateBiz.cs +++ b/server/AyaNova/biz/TravelRateBiz.cs @@ -178,7 +178,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/UnitBiz.cs b/server/AyaNova/biz/UnitBiz.cs index 455348ff..1ace56a3 100644 --- a/server/AyaNova/biz/UnitBiz.cs +++ b/server/AyaNova/biz/UnitBiz.cs @@ -176,7 +176,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/UnitModelBiz.cs b/server/AyaNova/biz/UnitModelBiz.cs index 7ca9b6e8..dd08a3db 100644 --- a/server/AyaNova/biz/UnitModelBiz.cs +++ b/server/AyaNova/biz/UnitModelBiz.cs @@ -177,7 +177,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/UserBiz.cs b/server/AyaNova/biz/UserBiz.cs index 89385369..4f8cf734 100644 --- a/server/AyaNova/biz/UserBiz.cs +++ b/server/AyaNova/biz/UserBiz.cs @@ -729,7 +729,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + //no need to rollback, the transaction will rollback automatically if it's disposed without committing throw; } diff --git a/server/AyaNova/biz/VendorBiz.cs b/server/AyaNova/biz/VendorBiz.cs index 110574f6..5f4e3587 100644 --- a/server/AyaNova/biz/VendorBiz.cs +++ b/server/AyaNova/biz/VendorBiz.cs @@ -174,7 +174,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/WidgetBiz.cs b/server/AyaNova/biz/WidgetBiz.cs index 3a475c9c..ea47ce4c 100644 --- a/server/AyaNova/biz/WidgetBiz.cs +++ b/server/AyaNova/biz/WidgetBiz.cs @@ -222,7 +222,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/WorkOrderBiz.cs b/server/AyaNova/biz/WorkOrderBiz.cs index af1df93b..c0b4b2c1 100644 --- a/server/AyaNova/biz/WorkOrderBiz.cs +++ b/server/AyaNova/biz/WorkOrderBiz.cs @@ -398,7 +398,7 @@ namespace AyaNova.Biz catch { //NOTE: no need to rollback the transaction, it will auto-rollback if not committed and it is disposed when it goes out of scope either way - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } @@ -535,36 +535,6 @@ namespace AyaNova.Biz } - // //////////////////////////////////////////////////////////////////////////////////////////////// - // //CONTRACT UPDATE - // // - // internal async Task ChangeContract(long workOrderId, long? newContractId) - // { - // //this is called by UI via contract change route for contract change only and expects wo back to update client ui - // var w = await ct.WorkOrder.FirstOrDefaultAsync(z => z.Id == workOrderId); - - // if (w == null) - // { - // AddError(ApiErrorCode.NOT_FOUND, "id"); - // return null; - // } - // if (newContractId != null && !await ct.Contract.AnyAsync(z => z.Id == newContractId)) - // { - // AddError(ApiErrorCode.NOT_FOUND, "generalerror", $"Contract with id {newContractId} not found"); - // return null; - // } - // w.ContractId = newContractId; - // await ct.SaveChangesAsync(); - // await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, workOrderId, BizType, AyaEvent.Modified), ct); - // await GetCurrentContractFromContractIdAsync(newContractId); - // var updatedWorkOrder = await ProcessChangeOfContractAsync(workOrderId); - // await WorkOrderPopulateVizFields(updatedWorkOrder, false); - // return updatedWorkOrder;//return entire workorder - // } - - - - //////////////////////////////////////////////////////////////////////////////////////////////// //GET WORKORDER ID FROM DESCENDANT TYPE AND ID // @@ -630,20 +600,6 @@ namespace AyaNova.Biz } - - // //////////////////////////////////////////////////////////////////////////////////////////////// - // //GET WORKORDER ID FOR WORK ORDER NUMBER - // // - // internal static async Task GetWorkOrderIdForNumberAsync(long woNumber, AyContext ct) - // { - // return await ct.WorkOrder.AsNoTracking() - // .Where(z => z.Serial == woNumber) - // .Select(z => z.Id) - // .SingleOrDefaultAsync(); - // } - - - //////////////////////////////////////////////////////////////////////////////////////////////// //SEARCH // @@ -773,42 +729,6 @@ namespace AyaNova.Biz } } - - - - /* - - todo: workorder status list first, it's a table of created items, keep properties from v7 but add the following properties: - SelectRoles - who can select the status (still shows if they can't select but that's the current status, like active does) - This is best handled at the client. It prefetches all the status out of the normal picklist process, more like how other things are separately handled now without a picklist - client then knows if a status is available or not and can process to only present available ones - #### Server can use a biz rule to ensure that it can't be circumvented - UI defaults to any role - DeselectRoles - who can unset this status (important for process control) - UI defaults to any role - CompletedStatus bool - this is a final status indicating all work on the workorder is completed, affects notification etc - UI defaults to false but when set to true auto sets lockworkorder to true (but user can just unset lockworkorder) - LockWorkorder - this status is considered read only and the workorder is locked - Just a read only thing, can just change status to "unlock" it - to support states where no one should work on a wo for whatever reason but it's not necessarily completed - e.g. "Hold for inspection", "On hold" generally etc - */ - // //Name required - // if (string.IsNullOrWhiteSpace(proposedObj.Name)) - // AddError(ApiErrorCode.VALIDATION_REQUIRED, "Name"); - - - // //If name is otherwise OK, check that name is unique - // if (!PropertyHasErrors("Name")) - // { - // //Use Any command is efficient way to check existance, it doesn't return the record, just a true or false - // if (await ct.WorkOrder.AnyAsync(z => z.Name == proposedObj.Name && z.Id != proposedObj.Id)) - // { - // AddError(ApiErrorCode.VALIDATION_NOT_UNIQUE, "Name"); - // } - // } - - //Any form customizations to validate? var FormCustomization = await ct.FormCustom.AsNoTracking().SingleOrDefaultAsync(z => z.FormKey == AyaType.WorkOrder.ToString()); if (FormCustomization != null) @@ -821,11 +741,9 @@ namespace AyaNova.Biz //validate custom fields CustomFieldsValidator.Validate(this, FormCustomization, proposedObj.CustomFields); } - } - private void WorkOrderValidateCanDelete(WorkOrder dbObject) { //Check restricted role preventing create @@ -834,43 +752,9 @@ namespace AyaNova.Biz AddError(ApiErrorCode.NOT_AUTHORIZED, "generalerror"); return;//this is a completely disqualifying error } - //FOREIGN KEY CHECKS - //these are examples copied from customer for when other objects are actually referencing them - // if (await ct.User.AnyAsync(m => m.CustomerId == inObj.Id)) - // AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("User")); - // if (await ct.Unit.AnyAsync(m => m.CustomerId == inObj.Id)) - // AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("Unit")); - // if (await ct.CustomerServiceRequest.AnyAsync(m => m.CustomerId == inObj.Id)) - // AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("CustomerServiceRequest")); - // if (await ct.PurchaseOrder.AnyAsync(m => m.DropShipToCustomerId == inObj.Id)) - // AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("PurchaseOrder")); } - //############### NOTIFICATION TODO - /* - - todo: workorder notifications remove #30 and #32 as redundant - WorkorderStatusChange = 4,//* Workorder object, any *change* of status including from no status (new) to a specific conditional status ID value - - WorkorderStatusAge = 24,//* Workorder object Created / Updated, conditional on exact status selected IdValue, Tags conditional, advance notice can be set - - //THESE TWO ARE REDUNDANT: - - this is actually workorderstatuschange because can just pick any status under workorderstatuschange to be notified about - WorkorderCompleted = 30, //*travel work order is set to any status that is flagged as a "Completed" type of status. Customer & User - - //This one could be accomplished with WorkorderStatusAge, just pick a Completed status and set a time frame and wala! - WorkorderCompletedFollowUp = 32, //* travel workorder closed status follow up again after this many TIMESPAN - - todo: CHANGE WorkorderCompletedStatusOverdue = 15,//* Workorder object not set to a "Completed" flagged workorder status type in selected time span from creation of workorder - Change this to a new type that is based on so many days *without* being set to a particular status - but first check if tied to contract response time stuff, how that's handled - that's closeby date in v7 but isn't that deprecated now without a "close"? - maybe I do need the Completed status bool thing above - - */ - //////////////////////////////////////////////////////////////////////////////////////////////// // GET PARTIAL WORKORDER FOR REPORTING @@ -882,24 +766,16 @@ namespace AyaNova.Biz //if it's the entire workorder just get, populate and return as normal if (ayaType == AyaType.WorkOrder) return await WorkOrderGetAsync(id, true, false, populateForReporting); - var wid = await GetWorkOrderIdFromRelativeAsync(ayaType, id, ct); - //get header only var ret = await ct.WorkOrder.AsNoTracking().SingleOrDefaultAsync(x => x.Id == wid.ParentId); - //not found don't bomb, just return null if (ret == null) return ret; - //explicit load subitems as required... - - WorkOrderItem woitem = null; - //it's requesting a fully populated woitem so do that here if (includeWoItemDescendants) { - woitem = await ct.WorkOrderItem.AsSplitQuery() .AsNoTracking() .Include(wi => wi.Expenses) @@ -982,64 +858,6 @@ namespace AyaNova.Biz foreach (long batchId in batch) batchResults.Add(await WorkOrderGetPartialAsync(dataListSelectedRequest.AType, batchId, dataListSelectedRequest.IncludeWoItemDescendants, true)); - #region unnecessary shit removed - //This is unnecessary because the re-ordering bit is only needed when the records are fetched in batches directly from the sql server as they - //return in db natural order and need to be put back into the same order as the ID List - //Here in the workorder however, this code is fetching individually one at a time so they are always going to be in the correct order so this re-ordering is unnecessary - //I'm keeping this here for future reference when I ineveitably wonder what the hell is happening here :) - - - //order the results back into original - //IEnumerable orderedList = null; - - //TODO: WHAT IS THIS BATCH RESULT ORDERING CODE REALLY DOING AND CAN IT BE REMOVED / CHANGED???? - //isn't it alredy working in order? If not maybe simply reversed so reverse it again before querying above or...?? - - //todo: can't assume the grandchild item is index 0 anymore as we might have multiple of them if includedescendants is true - //so need to find index first then do this - // switch (dataListSelectedRequest.AType) - // { - // case AyaType.WorkOrder: - // orderedList = from id in batch join z in batchResults on id equals z.Id select z; - // break; - // case AyaType.WorkOrderItem: - // orderedList = from id in batch join z in batchResults on id equals z.Items[0].Id select z; - // break; - // case AyaType.WorkOrderItemExpense: - // orderedList = from id in batch join z in batchResults on id equals z.Items[0].Expenses[0].Id select z; - // break; - // case AyaType.WorkOrderItemLabor: - // orderedList = from id in batch join z in batchResults on id equals z.Items[0].Labors[0].Id select z; - // break; - // case AyaType.WorkOrderItemLoan: - // orderedList = from id in batch join z in batchResults on id equals z.Items[0].Loans[0].Id select z; - // break; - // case AyaType.WorkOrderItemPart: - // orderedList = from id in batch join z in batchResults on id equals z.Items[0].Parts[0].Id select z; - // break; - // case AyaType.WorkOrderItemPartRequest: - // orderedList = from id in batch join z in batchResults on id equals z.Items[0].PartRequests[0].Id select z; - // break; - // case AyaType.WorkOrderItemScheduledUser: - // orderedList = from id in batch join z in batchResults on id equals z.Items[0].ScheduledUsers[0].Id select z; - // break; - // case AyaType.WorkOrderItemTask: - // orderedList = from id in batch join z in batchResults on id equals z.Items[0].Tasks[0].Id select z; - // break; - // case AyaType.WorkOrderItemTravel: - // orderedList = from id in batch join z in batchResults on id equals z.Items[0].Travels[0].Id select z; - // break; - // case AyaType.WorkOrderItemOutsideService: - // orderedList = from id in batch join z in batchResults on id equals z.Items[0].OutsideServices[0].Id select z; - // break; - // case AyaType.WorkOrderItemUnit: - // orderedList = from id in batch join z in batchResults on id equals z.Items[0].Units[0].Id select z; - // break; - // } - - //foreach (WorkOrder w in orderedList) - #endregion unnecessary shit - foreach (WorkOrder w in batchResults) { var jo = JObject.FromObject(w); @@ -1073,8 +891,6 @@ namespace AyaNova.Biz // private async Task WorkOrderPopulateVizFields(WorkOrder o, bool headerOnly, bool populateForReporting) { - - o.UserIsRestrictedType = UserIsRestrictedType; o.UserIsTechRestricted = UserIsTechRestricted; o.UserIsSubContractorFull = UserIsSubContractorFull; @@ -1120,16 +936,12 @@ namespace AyaNova.Biz } else o.ContractViz = "-"; - if (o.FromQuoteId != null) o.FromQuoteViz = await ct.Quote.AsNoTracking().Where(x => x.Id == o.FromQuoteId).Select(x => x.Serial.ToString()).FirstOrDefaultAsync(); - if (o.FromPMId != null) o.FromPMViz = await ct.PM.AsNoTracking().Where(x => x.Id == o.FromPMId).Select(x => x.Serial.ToString()).FirstOrDefaultAsync(); - if (o.FromCSRId != null) o.FromCSRViz = await ct.CustomerServiceRequest.AsNoTracking().Where(x => x.Id == o.FromCSRId).Select(x => x.Name).FirstOrDefaultAsync(); - } @@ -1144,32 +956,6 @@ namespace AyaNova.Biz return await GetReportData(dataListSelectedRequest); } - // public async Task> ImportData(JArray ja) - // { - // List ImportResult = new List(); - // string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}"; - - // var jsset = JsonSerializer.CreateDefault(new JsonSerializerSettings { ContractResolver = new AyaNova.Util.JsonUtil.ShouldSerializeContractResolver(new string[] { "Concurrency", "Id", "CustomFields" }) }); - // foreach (JObject j in ja) - // { - // var w = j.ToObject(jsset); - // if (j["CustomFields"] != null) - // w.CustomFields = j["CustomFields"].ToString(); - // w.Tags.Add(ImportTag);//so user can find them all and revert later if necessary - // var res = await WorkOrderCreateAsync(w); - // if (res == null) - // { - // ImportResult.Add($"* {w.Serial} - {this.GetErrorsAsString()}"); - // this.ClearErrors(); - // } - // else - // { - // ImportResult.Add($"{w.Serial} - ok"); - // } - // } - // return ImportResult; - // } - //////////////////////////////////////////////////////////////////////////////////////////////// //JOB / OPERATIONS // @@ -1258,17 +1044,11 @@ namespace AyaNova.Biz ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger(); if (ServerBootConfig.SEEDING) return; log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{this.BizType}, AyaEvent:{ayaEvent}]"); - bool isNew = currentObj == null; - WorkOrder oProposed = (WorkOrder)proposedObj; - - //STANDARD EVENTS FOR ALL OBJECTS await NotifyEventHelper.ProcessStandardObjectEvents(ayaEvent, proposedObj, ct);//Note: will properly handle all delete events and event removal if deleted - //SPECIFIC EVENTS FOR THIS OBJECT - WorkOrder oCurrent = null; bool SameTags = true; if (currentObj != null) @@ -1277,7 +1057,6 @@ namespace AyaNova.Biz SameTags = NotifyEventHelper.TwoObjectsHaveSameTags(proposedObj.Tags, currentObj.Tags); } - #region COMPLETE BY OVERDUE if (ayaEvent == AyaEvent.Created && oProposed.CompleteByDate != null) @@ -1594,45 +1373,31 @@ namespace AyaNova.Biz wo.DurationToCompleted = DateTime.UtcNow - wo.CreatedDate; else if (wo.DurationToCompleted != TimeSpan.Zero && !newStatusInfo.Completed) wo.DurationToCompleted = TimeSpan.Zero; - wo.LastStatusId = newObject.WorkOrderStatusId; - await ct.SaveChangesAsync(); - await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, AyaType.WorkOrderStatus, AyaEvent.Created), ct); await StateHandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } - //////////////////////////////////////////////////////////////////////////////////////////////// // GET // internal async Task StateGetAsync(long id, bool logTheGetEvent = true) { - //Note: there could be rules checking here in future, i.e. can only get own workorder or something - //if so, then need to implement AddError and in route handle Null return with Error check just like PUT route does now - - //https://docs.microsoft.com/en-us/ef/core/querying/related-data - //docs say this will not query twice but will recognize the duplicate woitem bit which is required for multiple grandchild collections var ret = await ct.WorkOrderState.AsNoTracking().SingleOrDefaultAsync(z => z.Id == id); if (logTheGetEvent && ret != null) await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, AyaType.WorkOrderStatus, AyaEvent.Retrieved), ct); return ret; } - - //////////////////////////////////////////////////////////////////////////////////////////////// //VIZ POPULATE // private async Task StatePopulateVizFields(WorkOrderState o) { - o.UserViz = await ct.User.AsNoTracking().Where(x => x.Id == o.UserId).Select(x => x.Name).FirstOrDefaultAsync(); - // if (o.WorkOrderOverseerId != null) - // o.WorkOrderOverseerViz = await ct.User.AsNoTracking().Where(x => x.Id == o.WorkOrderOverseerId).Select(x => x.Name).FirstOrDefaultAsync(); } //////////////////////////////////////////////////////////////////////////////////////////////// @@ -1656,7 +1421,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; @@ -1688,8 +1453,6 @@ namespace AyaNova.Biz } } - - //////////////////////////////////////////////////////////////////////////////////////////////// // NOTIFICATION PROCESSING // @@ -1720,20 +1483,12 @@ namespace AyaNova.Biz //NOTE: ID, state notifications are for the Workorder, not the state itself unlike other objects, so use the WO type and ID here for all notifications - - - //## DELETED EVENTS //A state cannot be deleted so nothing to handle that is required //a workorder CAN be deleted and it will automatically remove all events for it so also no need to remove time delayed status events either if wo is deleted. //so in essence there is nothing to be done regarding deleted events with states in a blanket way, however specific events below may remove them as appropriate - // await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, o.Id, NotifyEventType.WorkorderStatusChange); - // await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, o.Id, NotifyEventType.WorkorderCompletedStatusOverdue); - // await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, o.Id, NotifyEventType.WorkorderStatusAge); - - //## CREATED (this is the only possible notification CREATION ayaEvent type for a workorder state as they are create only) if (ayaEvent == AyaEvent.Created) { @@ -1974,13 +1729,12 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, AyaType.WorkOrderItem, AyaEvent.Created), ct); await ItemSearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await ItemHandlePotentialNotificationEvent(AyaEvent.Created, newObject); await ItemPopulateVizFields(newObject, false); + await ItemHandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } - //////////////////////////////////////////////////////////////////////////////////////////////// // GET // @@ -2047,8 +1801,6 @@ namespace AyaNova.Biz if (HasErrors) return null; ct.Replace(dbObject, putObject); - - try { await ct.SaveChangesAsync(); @@ -2064,8 +1816,8 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, putObject.Id, AyaType.WorkOrderItem, AyaEvent.Modified), ct); await ItemSearchIndexAsync(putObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, putObject.Tags, dbObject.Tags); - await ItemHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); await ItemPopulateVizFields(putObject, false); + await ItemHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); return putObject; } @@ -2147,7 +1899,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; @@ -2179,9 +1931,6 @@ namespace AyaNova.Biz // private async Task ItemPopulateVizFields(WorkOrderItem o, bool populateForReporting) { - // if (o.WorkOrderOverseerId != null) - // o.WorkOrderOverseerViz = await ct.User.AsNoTracking().Where(x => x.Id == o.WorkOrderOverseerId).Select(x => x.Name).FirstOrDefaultAsync(); - foreach (var v in o.Expenses) await ExpensePopulateVizFields(v); foreach (var v in o.Labors) @@ -2202,8 +1951,6 @@ namespace AyaNova.Biz await TravelPopulateVizFields(v); foreach (var v in o.Units) await UnitPopulateVizFields(v, populateForReporting); - - } //////////////////////////////////////////////////////////////////////////////////////////////// @@ -2272,8 +2019,6 @@ namespace AyaNova.Biz AddError(ApiErrorCode.NOT_AUTHORIZED, "generalerror"); return;//this is a completely disqualifying error } - - //re-check rights here necessary due to traversal delete from Principle object if (!Authorized.HasDeleteRole(CurrentUserRoles, AyaType.WorkOrderItem)) { @@ -2310,22 +2055,6 @@ namespace AyaNova.Biz //SPECIFIC EVENTS FOR THIS OBJECT - //## DELETED EVENTS - //any event added below needs to be removed, so - //just blanket remove any event for this object of eventtype that would be added below here - //do it regardless any time there's an update and then - //let this code below handle the refreshing addition that could have changes - // await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, o.Id, NotifyEventType.ContractExpiring); - - - //## CREATED / MODIFIED EVENTS - if (ayaEvent == AyaEvent.Created || ayaEvent == AyaEvent.Modified) - { - - //todo: fix etc, tons of shit here incoming - - } - }//end of process notifications @@ -2364,9 +2093,8 @@ namespace AyaNova.Biz await ct.SaveChangesAsync(); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); await ExpenseSearchIndexAsync(newObject, true); - - await ExpenseHandlePotentialNotificationEvent(AyaEvent.Created, newObject); await ExpensePopulateVizFields(newObject); + await ExpenseHandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -2423,8 +2151,8 @@ namespace AyaNova.Biz } await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, putObject.Id, putObject.AyaType, AyaEvent.Modified), ct); await ExpenseSearchIndexAsync(putObject, false); - await ExpenseHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); await ExpensePopulateVizFields(putObject); + await ExpenseHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); return putObject; } @@ -2442,19 +2170,16 @@ namespace AyaNova.Biz return false; ct.WorkOrderItemExpense.Remove(dbObject); await ct.SaveChangesAsync(); - //Log event await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix?? await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); - - if (parentTransaction == null) await transaction.CommitAsync(); await ExpenseHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; @@ -2544,22 +2269,18 @@ namespace AyaNova.Biz //run validation and biz rules bool isNew = currentObj == null; - if (UserIsSubContractorFull || UserIsSubContractorRestricted) { //no edits allowed AddError(ApiErrorCode.NOT_AUTHORIZED, "generalerror"); return; } - if (UserIsRestrictedType && (proposedObj.UserId != UserId || (!isNew && currentObj.UserId != UserId))) { //no edits allowed on other people's records AddError(ApiErrorCode.NOT_AUTHORIZED); return; } - - if (proposedObj.WorkOrderItemId == 0) { AddError(ApiErrorCode.VALIDATION_REQUIRED, "WorkOrderItemId"); @@ -2570,7 +2291,6 @@ namespace AyaNova.Biz AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "WorkOrderItemId"); return;//this is a completely disqualifying error } - //Check state if updatable right now if (!isNew) { @@ -2727,15 +2447,12 @@ namespace AyaNova.Biz return null; else { - await ct.WorkOrderItemLabor.AddAsync(newObject); await ct.SaveChangesAsync(); - await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); await LaborSearchIndexAsync(newObject, true); - - await LaborHandlePotentialNotificationEvent(AyaEvent.Created, newObject); await LaborPopulateVizFields(newObject); + await LaborHandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -2773,8 +2490,6 @@ namespace AyaNova.Biz AddError(ApiErrorCode.CONCURRENCY_CONFLICT); return null; } - - await LaborValidateAsync(putObject, dbObject); if (HasErrors) return null; ct.Replace(dbObject, putObject); @@ -2792,9 +2507,8 @@ namespace AyaNova.Biz } await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, putObject.AyaType, AyaEvent.Modified), ct); await LaborSearchIndexAsync(putObject, false); - - await LaborHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); await LaborPopulateVizFields(putObject); + await LaborHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); return putObject; } @@ -2816,21 +2530,18 @@ namespace AyaNova.Biz //Log event await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix?? await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); - - if (parentTransaction == null) await transaction.CommitAsync(); await LaborHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; } - ////////////////////////////////////////////// //INDEXING // @@ -2961,14 +2672,11 @@ namespace AyaNova.Biz } } o.LineTotalViz = o.NetViz + o.TaxAViz + o.TaxBViz; - - //RESTRICTIONS ON COST VISIBILITY? if (!UserCanViewLaborOrTravelRateCosts) { o.CostViz = 0; } - } @@ -3014,7 +2722,6 @@ namespace AyaNova.Biz return; } - //Start date AND end date must both be null or both contain values if (proposedObj.ServiceStartDate == null && proposedObj.ServiceStopDate != null) AddError(ApiErrorCode.VALIDATION_REQUIRED, "ServiceStartDate"); @@ -3043,11 +2750,9 @@ namespace AyaNova.Biz RequiredFieldsValidator.Validate(this, FormCustomization, proposedObj);//note: this is passed only to add errors //validate custom fields - } } - private void LaborValidateCanDelete(WorkOrderItemLabor obj) { if (obj == null) @@ -3055,7 +2760,6 @@ namespace AyaNova.Biz AddError(ApiErrorCode.NOT_FOUND, "id"); return; } - if (UserIsRestrictedType) { //Labors: add (no user selection defaults to themselves), remove, view and edit only when they are the selected User @@ -3063,7 +2767,6 @@ namespace AyaNova.Biz AddError(ApiErrorCode.NOT_AUTHORIZED, "generalerror"); return; } - //re-check rights here necessary due to traversal delete from Principle object if (!Authorized.HasDeleteRole(CurrentUserRoles, AyaType.WorkOrderItemLabor)) { @@ -3091,13 +2794,11 @@ namespace AyaNova.Biz oProposed.Name = WorkorderInfo.Serial.ToString(); oProposed.Tags = WorkorderInfo.Tags; - //STANDARD EVENTS FOR ALL OBJECTS await NotifyEventHelper.ProcessStandardObjectEvents(ayaEvent, proposedObj, ct); //SPECIFIC EVENTS FOR THIS OBJECT - }//end of process notifications #endregion work order item LABOR level @@ -3134,9 +2835,8 @@ namespace AyaNova.Biz await ct.SaveChangesAsync(); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); await LoanSearchIndexAsync(newObject, true); - - await LoanHandlePotentialNotificationEvent(AyaEvent.Created, newObject); await LoanPopulateVizFields(newObject); + await LoanHandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -3148,7 +2848,6 @@ namespace AyaNova.Biz { if (UserIsSubContractorRestricted) //no access allowed at all return null; - var ret = await ct.WorkOrderItemLoan.AsNoTracking().SingleOrDefaultAsync(z => z.Id == id); if (logTheGetEvent && ret != null) await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, ret.AyaType, AyaEvent.Retrieved), ct); @@ -3171,7 +2870,6 @@ namespace AyaNova.Biz AddError(ApiErrorCode.CONCURRENCY_CONFLICT); return null; } - await LoanValidateAsync(putObject, dbObject); if (HasErrors) return null; await LoanBizActionsAsync(AyaEvent.Modified, putObject, dbObject, null); @@ -3190,9 +2888,8 @@ namespace AyaNova.Biz } await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, putObject.AyaType, AyaEvent.Modified), ct); await LoanSearchIndexAsync(putObject, false); - - await LoanHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); await LoanPopulateVizFields(putObject); + await LoanHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); return putObject; } @@ -3214,15 +2911,12 @@ namespace AyaNova.Biz //Log event await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix?? await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); - - if (parentTransaction == null) await transaction.CommitAsync(); await LoanHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here throw; } return true; @@ -3447,11 +3141,9 @@ namespace AyaNova.Biz RequiredFieldsValidator.Validate(this, FormCustomization, proposedObj);//note: this is passed only to add errors //validate custom fields - } } - private void LoanValidateCanDelete(WorkOrderItemLoan obj) { if (UserIsRestrictedType) @@ -3460,13 +3152,11 @@ namespace AyaNova.Biz AddError(ApiErrorCode.NOT_AUTHORIZED, "generalerror"); return; } - if (obj == null) { AddError(ApiErrorCode.NOT_FOUND, "id"); return; } - //re-check rights here necessary due to traversal delete from Principle object if (!Authorized.HasDeleteRole(CurrentUserRoles, AyaType.WorkOrderItemLoan)) { @@ -3476,8 +3166,6 @@ namespace AyaNova.Biz } - - //////////////////////////////////////////////////////////////////////////////////////////////// // NOTIFICATION PROCESSING // @@ -3540,15 +3228,12 @@ namespace AyaNova.Biz return null; else { - // newObject.Tags = TagBiz.NormalizeTags(newObject.Tags); - await ct.WorkOrderItemOutsideService.AddAsync(newObject); await ct.SaveChangesAsync(); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); await OutsideServiceSearchIndexAsync(newObject, true); - - await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Created, newObject); await OutsideServicePopulateVizFields(newObject); + await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -3582,7 +3267,6 @@ namespace AyaNova.Biz AddError(ApiErrorCode.CONCURRENCY_CONFLICT); return null; } - await OutsideServiceValidateAsync(putObject, dbObject); if (HasErrors) return null; ct.Replace(dbObject, putObject); @@ -3600,10 +3284,8 @@ namespace AyaNova.Biz } await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, putObject.Id, putObject.AyaType, AyaEvent.Modified), ct); await OutsideServiceSearchIndexAsync(putObject, false); - - - await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); await OutsideServicePopulateVizFields(putObject); + await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); return putObject; } @@ -3625,15 +3307,12 @@ namespace AyaNova.Biz //Log event await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix?? await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); - - if (parentTransaction == null) await transaction.CommitAsync(); await OutsideServiceHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here throw; } return true; @@ -4025,7 +3704,6 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); await PartSearchIndexAsync(newObject, true); await transaction.CommitAsync(); - await PartPopulateVizFields(newObject); await PartHandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; @@ -4066,9 +3744,6 @@ namespace AyaNova.Biz return null; } - - - await PartValidateAsync(putObject, dbObject); if (HasErrors) return null; await PartBizActionsAsync(AyaEvent.Modified, putObject, dbObject, null); @@ -4126,14 +3801,12 @@ namespace AyaNova.Biz await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix?? await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); - if (parentTransaction == null) await transaction.CommitAsync(); await PartHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here throw; } return true; @@ -4307,11 +3980,9 @@ namespace AyaNova.Biz //maintain old cost as it can come from the client as zero when it shouldn't be or someone using the api and setting it directly //but we will only allow the price *we* set at the server initially newObj.Cost = oldObj.Cost; - } } - //Pricing if (SnapshotPricing) { @@ -4335,8 +4006,6 @@ namespace AyaNova.Biz // private async Task PartInventoryAdjustmentAsync(AyaEvent ayaEvent, WorkOrderItemPart newObj, WorkOrderItemPart oldObj, IDbContextTransaction transaction) { - - if (AyaNova.Util.ServerGlobalBizSettings.Cache.UseInventory) { PartInventoryBiz pib = new PartInventoryBiz(ct, UserId, UserTranslationId, CurrentUserRoles); @@ -4433,7 +4102,6 @@ namespace AyaNova.Biz } } - //IN with the new if (newObj.Quantity != 0) {//NOTE: zero quantity is considered to be a placeholder and no serials will be consumed, nor inventory affected @@ -4587,13 +4255,8 @@ namespace AyaNova.Biz //SPECIFIC EVENTS FOR THIS OBJECT - }//end of process notifications - - - - #endregion work order item PARTS level @@ -4624,15 +4287,11 @@ namespace AyaNova.Biz return null; else { - - await ct.WorkOrderItemPartRequest.AddAsync(newObject); await ct.SaveChangesAsync(); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); - //await PartRequestSearchIndexAsync(newObject, true); - - await PartRequestHandlePotentialNotificationEvent(AyaEvent.Created, newObject); await PartRequestPopulateVizFields(newObject); + await PartRequestHandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -4666,8 +4325,6 @@ namespace AyaNova.Biz AddError(ApiErrorCode.CONCURRENCY_CONFLICT); return null; } - - await PartRequestValidateAsync(putObject, dbObject); if (HasErrors) return null; ct.Replace(dbObject, putObject); @@ -4684,10 +4341,8 @@ namespace AyaNova.Biz return null; } await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, putObject.Id, putObject.AyaType, AyaEvent.Modified), ct); - - - await PartRequestHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); await PartRequestPopulateVizFields(putObject); + await PartRequestHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); return putObject; } @@ -4705,19 +4360,15 @@ namespace AyaNova.Biz return false; ct.WorkOrderItemPartRequest.Remove(dbObject); await ct.SaveChangesAsync(); - //Log event await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix?? await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); - - if (parentTransaction == null) await transaction.CommitAsync(); await PartRequestHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here throw; } return true; @@ -4803,22 +4454,17 @@ namespace AyaNova.Biz if (proposedObj.Quantity < 0)//negative quantities are not allowed AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Quantity"); - //Any form customizations to validate? var FormCustomization = await ct.FormCustom.AsNoTracking().SingleOrDefaultAsync(z => z.FormKey == AyaType.WorkOrderItemPartRequest.ToString()); if (FormCustomization != null) { //Yeppers, do the validation, there are two, the custom fields and the regular fields that might be set to required - //validate users choices for required non custom fields RequiredFieldsValidator.Validate(this, FormCustomization, proposedObj);//note: this is passed only to add errors - //validate custom fields - } } - private void PartRequestValidateCanDelete(WorkOrderItemPartRequest obj) { @@ -4900,15 +4546,11 @@ namespace AyaNova.Biz return null; else { - - await ct.WorkOrderItemScheduledUser.AddAsync(newObject); await ct.SaveChangesAsync(); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); - - - await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Created, newObject); await ScheduledUserPopulateVizFields(newObject); + await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -4942,9 +4584,6 @@ namespace AyaNova.Biz AddError(ApiErrorCode.CONCURRENCY_CONFLICT); return null; } - - - await ScheduledUserValidateAsync(putObject, dbObject); if (HasErrors) return null; ct.Replace(dbObject, putObject); @@ -4961,10 +4600,8 @@ namespace AyaNova.Biz return null; } await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, putObject.AyaType, AyaEvent.Modified), ct); - - - await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); await ScheduledUserPopulateVizFields(putObject); + await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); return putObject; } @@ -4974,29 +4611,21 @@ namespace AyaNova.Biz internal async Task ScheduledUserDeleteAsync(long id, IDbContextTransaction parentTransaction = null) { var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync(); - try - { - var dbObject = await ScheduledUserGetAsync(id, false); - ScheduledUserValidateCanDelete(dbObject); - if (HasErrors) - return false; - ct.WorkOrderItemScheduledUser.Remove(dbObject); - await ct.SaveChangesAsync(); - //Log event - await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix?? - await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); + var dbObject = await ScheduledUserGetAsync(id, false); + ScheduledUserValidateCanDelete(dbObject); + if (HasErrors) + return false; + ct.WorkOrderItemScheduledUser.Remove(dbObject); + await ct.SaveChangesAsync(); + //Log event + await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix?? + await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); + if (parentTransaction == null) + await transaction.CommitAsync(); + await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); - if (parentTransaction == null) - await transaction.CommitAsync(); - await ScheduledUserHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); - } - catch - { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here - throw; - } return true; } @@ -5089,9 +4718,7 @@ namespace AyaNova.Biz AddError(ApiErrorCode.VALIDATION_FAILED, "StartDate", await Translate("ScheduleConflict")); AddError(ApiErrorCode.VALIDATION_FAILED, "StopDate", await Translate("ScheduleConflict")); } - } - //Any form customizations to validate? var FormCustomization = await ct.FormCustom.AsNoTracking().SingleOrDefaultAsync(z => z.FormKey == AyaType.WorkOrderItemScheduledUser.ToString()); if (FormCustomization != null) @@ -5106,7 +4733,6 @@ namespace AyaNova.Biz } } - private void ScheduledUserValidateCanDelete(WorkOrderItemScheduledUser obj) { if (obj == null) @@ -5228,7 +4854,6 @@ namespace AyaNova.Biz } - //## MODIFIED if (ayaEvent == AyaEvent.Modified) { @@ -5270,8 +4895,6 @@ namespace AyaNova.Biz }//end of process notifications - - #endregion work order item SCHEDULED USER level @@ -5302,15 +4925,12 @@ namespace AyaNova.Biz return null; else { - - await ct.WorkOrderItemTask.AddAsync(newObject); await ct.SaveChangesAsync(); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); await TaskSearchIndexAsync(newObject, true); - - await TaskHandlePotentialNotificationEvent(AyaEvent.Created, newObject); await TaskPopulateVizFields(newObject); + await TaskHandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -5342,8 +4962,6 @@ namespace AyaNova.Biz AddError(ApiErrorCode.CONCURRENCY_CONFLICT); return null; } - - await TaskValidateAsync(putObject, dbObject); if (HasErrors) return null; ct.Replace(dbObject, putObject); @@ -5361,9 +4979,8 @@ namespace AyaNova.Biz } await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, putObject.AyaType, AyaEvent.Modified), ct); await TaskSearchIndexAsync(dbObject, false); - - await TaskHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); await TaskPopulateVizFields(putObject); + await TaskHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); return putObject; } @@ -5373,29 +4990,18 @@ namespace AyaNova.Biz internal async Task TaskDeleteAsync(long id, IDbContextTransaction parentTransaction = null) { var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync(); - try - { - var dbObject = await TaskGetAsync(id, false); - TaskValidateCanDelete(dbObject); - if (HasErrors) - return false; - ct.WorkOrderItemTask.Remove(dbObject); - await ct.SaveChangesAsync(); - - //Log event - await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix?? - await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); - - - if (parentTransaction == null) - await transaction.CommitAsync(); - await TaskHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); - } - catch - { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here - throw; - } + var dbObject = await TaskGetAsync(id, false); + TaskValidateCanDelete(dbObject); + if (HasErrors) + return false; + ct.WorkOrderItemTask.Remove(dbObject); + await ct.SaveChangesAsync(); + //Log event + await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix?? + await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); + if (parentTransaction == null) + await transaction.CommitAsync(); + await TaskHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); return true; } @@ -5507,13 +5113,10 @@ namespace AyaNova.Biz //validate users choices for required non custom fields RequiredFieldsValidator.Validate(this, FormCustomization, proposedObj);//note: this is passed only to add errors - //validate custom fields - } } - private void TaskValidateCanDelete(WorkOrderItemTask obj) { if (obj == null) @@ -5537,7 +5140,6 @@ namespace AyaNova.Biz } } - //////////////////////////////////////////////////////////////////////////////////////////////// // NOTIFICATION PROCESSING // @@ -5559,7 +5161,6 @@ namespace AyaNova.Biz //SPECIFIC EVENTS FOR THIS OBJECT - }//end of process notifications @@ -5597,8 +5198,8 @@ namespace AyaNova.Biz await ct.SaveChangesAsync(); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); await TravelSearchIndexAsync(newObject, true); - await TravelHandlePotentialNotificationEvent(AyaEvent.Created, newObject); await TravelPopulateVizFields(newObject); + await TravelHandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -5653,9 +5254,8 @@ namespace AyaNova.Biz } await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, putObject.AyaType, AyaEvent.Modified), ct); await TravelSearchIndexAsync(putObject, false); - - await TravelHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); await TravelPopulateVizFields(putObject); + await TravelHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); return putObject; } @@ -5665,29 +5265,19 @@ namespace AyaNova.Biz internal async Task TravelDeleteAsync(long id, IDbContextTransaction parentTransaction = null) { var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync(); - try - { - var dbObject = await TravelGetAsync(id, false); - TravelValidateCanDelete(dbObject); - if (HasErrors) - return false; - ct.WorkOrderItemTravel.Remove(dbObject); - await ct.SaveChangesAsync(); + var dbObject = await TravelGetAsync(id, false); + TravelValidateCanDelete(dbObject); + if (HasErrors) + return false; + ct.WorkOrderItemTravel.Remove(dbObject); + await ct.SaveChangesAsync(); - //Log event - await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct); - await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); - - - if (parentTransaction == null) - await transaction.CommitAsync(); - await TravelHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); - } - catch - { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here - throw; - } + //Log event + await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct); + await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); + if (parentTransaction == null) + await transaction.CommitAsync(); + await TravelHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); return true; } @@ -5889,11 +5479,9 @@ namespace AyaNova.Biz RequiredFieldsValidator.Validate(this, FormCustomization, proposedObj);//note: this is passed only to add errors //validate custom fields - } } - private void TravelValidateCanDelete(WorkOrderItemTravel obj) { if (obj == null) @@ -5972,16 +5560,11 @@ namespace AyaNova.Biz // internal async Task UnitCreateAsync(WorkOrderItemUnit newObject) { - - - - await UnitValidateAsync(newObject, null); if (HasErrors) return null; else { - newObject.Tags = TagBiz.NormalizeTags(newObject.Tags); newObject.CustomFields = JsonUtil.CompactJson(newObject.CustomFields); await ct.WorkOrderItemUnit.AddAsync(newObject); @@ -5989,9 +5572,8 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, newObject.AyaType, AyaEvent.Created), ct); await UnitSearchIndexAsync(newObject, true); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null); - await UnitHandlePotentialNotificationEvent(AyaEvent.Created, newObject); await UnitPopulateVizFields(newObject, false); - + await UnitHandlePotentialNotificationEvent(AyaEvent.Created, newObject); return newObject; } } @@ -6030,8 +5612,6 @@ namespace AyaNova.Biz dbObject.CustomFields = JsonUtil.CompactJson(dbObject.CustomFields); await UnitValidateAsync(putObject, dbObject); if (HasErrors) return null; - - ct.Replace(dbObject, putObject); try { @@ -6048,10 +5628,8 @@ namespace AyaNova.Biz await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, putObject.AyaType, AyaEvent.Modified), ct); await UnitSearchIndexAsync(putObject, false); await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, putObject.Tags, dbObject.Tags); - await UnitHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); await UnitPopulateVizFields(putObject, false); - - + await UnitHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject); return putObject; } @@ -6061,31 +5639,21 @@ namespace AyaNova.Biz internal async Task UnitDeleteAsync(long id, IDbContextTransaction parentTransaction = null) { var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync(); - try - { - var dbObject = await UnitGetAsync(id, false); - UnitValidateCanDelete(dbObject); - if (HasErrors) - return false; - ct.WorkOrderItemUnit.Remove(dbObject); - await ct.SaveChangesAsync(); - - //Log event - await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix?? - await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); - if (parentTransaction == null) - await transaction.CommitAsync(); - await UnitHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); - } - catch - { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here - throw; - } + var dbObject = await UnitGetAsync(id, false); + UnitValidateCanDelete(dbObject); + if (HasErrors) + return false; + ct.WorkOrderItemUnit.Remove(dbObject); + await ct.SaveChangesAsync(); + //Log event + await EventLogProcessor.DeleteObjectLogAsync(UserId, dbObject.AyaType, dbObject.Id, "woitem:" + dbObject.WorkOrderItemId.ToString(), ct);//Fix?? + await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, dbObject.AyaType, ct); + if (parentTransaction == null) + await transaction.CommitAsync(); + await UnitHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject); return true; } - ////////////////////////////////////////////// //INDEXING // @@ -6111,42 +5679,6 @@ namespace AyaNova.Biz } - - - - // //////////////////////////////////////////////////////////////////////////////////////////////// - // //BIZ ACTIONS - // // - // // - // private async Task UnitBizActionsAsync(AyaEvent ayaEvent, WorkOrderItemUnit newObj, WorkOrderItemUnit oldObj, IDbContextTransaction transaction) - // { - // //automatic actions on record change, called AFTER validation - - // //currently no processing required except for created or modified at this time - // if (ayaEvent != AyaEvent.Created && ayaEvent != AyaEvent.Modified) - // return; - - - // if (newOrChangedActiveUnitContract != null && (ayaEvent == AyaEvent.Modified || ayaEvent == AyaEvent.Created))//note: keeping this qualification defensively in case more biz actions added later - // { - // //set contract if applicable - // //Note: validation has already set neworchangeactiveunitcontract and only sets it if it's applicable - // //so in here we just need to apply that contract to the header - // //I've decided that it will attempt to set the header here now rather than after the unit has set - // //as it's more important to have the unit record be saved than to - - - // // //If it wasn't a complete part change there is no need to set pricing - // // if (newObj.LoanUnitId == oldObj.LoanUnitId && newObj.Rate == oldObj.Rate) - // // { - // // SnapshotPricing = false; - // // //maintain old cost as it can come from the client as zero when it shouldn't be or someone using the api and setting it directly - // // //but we will only allow the price *we* set at the server initially - // // newObj.Cost = oldObj.Cost; - // // } - // } - // } - //////////////////////////////////////////////////////////////////////////////////////////////// //VIZ POPULATE // @@ -6158,7 +5690,6 @@ namespace AyaNova.Biz .FirstOrDefaultAsync(); o.UnitViz = unitInfo.Serial; o.UnitDescriptionViz = unitInfo.Description; - if (populateForReporting) { o.AddressViz = unitInfo.Address; @@ -6168,7 +5699,6 @@ namespace AyaNova.Biz o.LatitudeViz = unitInfo.Latitude; o.LongitudeViz = unitInfo.Longitude; } - if (unitInfo.UnitModelId != null) { var unitModelInfo = await ct.UnitModel.AsNoTracking().Where(x => x.Id == unitInfo.UnitModelId).Select(x => new { x.Name, x.VendorId, x.Number }).FirstOrDefaultAsync(); @@ -6188,8 +5718,6 @@ namespace AyaNova.Biz //skip validation if seeding // if (ServerBootConfig.SEEDING) return; - // - A work order *MUST* have only one Unit with a Contract, if there is already a unit with a contract on this workorder then a new one cannot be added and it will reject with a validation error - //run validation and biz rules bool isNew = currentObj == null; @@ -6240,7 +5768,6 @@ namespace AyaNova.Biz } } - private void UnitValidateCanDelete(WorkOrderItemUnit obj) { if (UserIsRestrictedType) @@ -6264,7 +5791,6 @@ namespace AyaNova.Biz } } - //////////////////////////////////////////////////////////////////////////////////////////////// // NOTIFICATION PROCESSING // @@ -6285,7 +5811,6 @@ namespace AyaNova.Biz //SPECIFIC EVENTS FOR THIS OBJECT - }//end of process notifications diff --git a/server/AyaNova/biz/WorkOrderItemPriorityBiz.cs b/server/AyaNova/biz/WorkOrderItemPriorityBiz.cs index 3b334863..425dbb17 100644 --- a/server/AyaNova/biz/WorkOrderItemPriorityBiz.cs +++ b/server/AyaNova/biz/WorkOrderItemPriorityBiz.cs @@ -159,7 +159,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/WorkOrderItemStatusBiz.cs b/server/AyaNova/biz/WorkOrderItemStatusBiz.cs index 7be891e4..b34f2e17 100644 --- a/server/AyaNova/biz/WorkOrderItemStatusBiz.cs +++ b/server/AyaNova/biz/WorkOrderItemStatusBiz.cs @@ -159,7 +159,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true; diff --git a/server/AyaNova/biz/WorkOrderStatusBiz.cs b/server/AyaNova/biz/WorkOrderStatusBiz.cs index 569ab5b8..5752dd12 100644 --- a/server/AyaNova/biz/WorkOrderStatusBiz.cs +++ b/server/AyaNova/biz/WorkOrderStatusBiz.cs @@ -159,7 +159,7 @@ namespace AyaNova.Biz } catch { - //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here + throw; } return true;