This commit is contained in:
2021-02-11 00:53:48 +00:00
parent 0749539172
commit 8fdfa3482d
9 changed files with 72 additions and 48 deletions

View File

@@ -156,7 +156,7 @@ namespace AyaNova.Biz
AddError(ApiErrorCode.NOT_FOUND);
return false;
}
ValidateCanDelete(dbObject);
await ValidateCanDeleteAsync(dbObject);
if (HasErrors)
return false;
if (HasErrors)
@@ -255,9 +255,13 @@ namespace AyaNova.Biz
}
private void ValidateCanDelete(Contract inObj)
private async Task ValidateCanDeleteAsync(Contract inObj)
{
//whatever needs to be check to delete this object
//FOREIGN KEY CHECKS
if (await ct.Customer.AnyAsync(m => m.ContractId == inObj.Id))
AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("Customer"));
if (await ct.HeadOffice.AnyAsync(m => m.ContractId == inObj.Id))
AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("HeadOffice"));
}