This commit is contained in:
@@ -160,7 +160,7 @@ namespace AyaNova.Biz
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
await ValidateCanDelete(dbObject);
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.PartWarehouse.Remove(dbObject);
|
||||
@@ -257,24 +257,20 @@ namespace AyaNova.Biz
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ValidateCanDelete(PartWarehouse inObj)
|
||||
{
|
||||
|
||||
//Can't delete the default warehouse
|
||||
|
||||
private async Task ValidateCanDeleteAsync(PartWarehouse inObj)
|
||||
{//Can't delete the default warehouse
|
||||
if (inObj.Id == 1)
|
||||
{
|
||||
AddError(ApiErrorCode.INVALID_OPERATION, "generalerror", "Default part warehouse can not be deleted");
|
||||
return;//nothing more need be checked this is completetly disqualifying
|
||||
}
|
||||
|
||||
//FOREIGN KEY CHECKS
|
||||
|
||||
//PartInventory record?
|
||||
//Referential integrity
|
||||
if (await ct.PartInventory.AnyAsync(m => m.PartWarehouseId == inObj.Id))
|
||||
{
|
||||
AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("PartInventoryTransaction"));
|
||||
|
||||
}
|
||||
if (await ct.PartStockLevel.AnyAsync(m => m.PartWarehouseId == inObj.Id))
|
||||
AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("PartStockingLevels"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user