This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user