This commit is contained in:
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -53,7 +53,7 @@
|
||||
"AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles",
|
||||
"AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles",
|
||||
"AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles",
|
||||
"AYANOVA_SERVER_TEST_MODE": "true",
|
||||
"AYANOVA_SERVER_TEST_MODE": "false",
|
||||
"AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small",
|
||||
"AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7",
|
||||
"AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_13\\bin\\"
|
||||
|
||||
@@ -151,9 +151,7 @@ namespace AyaNova.Biz
|
||||
try
|
||||
{
|
||||
Customer dbObject = await ct.Customer.SingleOrDefaultAsync(z => z.Id == id);
|
||||
ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
await ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.Customer.Remove(dbObject);
|
||||
@@ -169,6 +167,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;
|
||||
}
|
||||
@@ -246,9 +245,20 @@ namespace AyaNova.Biz
|
||||
|
||||
}
|
||||
|
||||
private void ValidateCanDelete(Customer inObj)
|
||||
|
||||
private async Task ValidateCanDelete(Customer inObj)
|
||||
{
|
||||
//whatever needs to be check to delete this object
|
||||
//## NOTE: contact isn't so important, this could be changed to check only more important things like workorders etc
|
||||
//and just attempt to delete all the contacts if possible, but for now....
|
||||
|
||||
//Referential integrity error
|
||||
if (await ct.User.AnyAsync(z => z.CustomerId == inObj.Id) == true)
|
||||
{
|
||||
//Note: errorbox will ensure it appears in the general errror box and not field specific
|
||||
//the translation key is to indicate what the linked object is that is causing the error
|
||||
AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "errorbox", "LT:Contact");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ namespace AyaNova.Biz
|
||||
try
|
||||
{
|
||||
Report dbObject = await ct.Report.SingleOrDefaultAsync(z => z.Id == id);
|
||||
ValidateCanDelete(dbObject);
|
||||
await ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.Report.Remove(dbObject);
|
||||
@@ -296,16 +296,15 @@ namespace AyaNova.Biz
|
||||
|
||||
}
|
||||
|
||||
private async void ValidateCanDelete(Report inObj)
|
||||
private async Task ValidateCanDelete(Report inObj)
|
||||
{
|
||||
|
||||
//TODO: this is shitty, needs to mention notifications to be maximally useful
|
||||
//Referential integrity error
|
||||
if (await ct.NotifySubscription.AnyAsync(z => z.LinkReportId == inObj.Id) == true)
|
||||
{
|
||||
AddError(ApiErrorCode.INVALID_OPERATION, null, "LT:ErrorDBForeignKeyViolation");
|
||||
return;
|
||||
//Note: errorbox will ensure it appears in the general errror box and not field specific
|
||||
//the translation key is to indicate what the linked object is that is causing the error
|
||||
AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "errorbox", "LT:NotifySubscription");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -153,9 +153,7 @@ namespace AyaNova.Biz
|
||||
Vendor dbObject = await ct.Vendor.SingleOrDefaultAsync(z => z.Id == id);
|
||||
ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
return false;
|
||||
ct.Vendor.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
|
||||
@@ -609,6 +609,7 @@ namespace AyaNova.Util
|
||||
|
||||
|
||||
|
||||
|
||||
}//eoc
|
||||
|
||||
}//eons
|
||||
Reference in New Issue
Block a user