This commit is contained in:
2020-12-03 23:54:57 +00:00
parent 0b7610be86
commit a7fdbcf0fd
5 changed files with 24 additions and 16 deletions

View File

@@ -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");
}
}