This commit is contained in:
@@ -155,9 +155,7 @@ namespace AyaNova.Biz
|
|||||||
AddError(ApiErrorCode.NOT_FOUND);
|
AddError(ApiErrorCode.NOT_FOUND);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ValidateCanDelete(dbObject);
|
await ValidateCanDelete(dbObject);
|
||||||
if (HasErrors)
|
|
||||||
return false;
|
|
||||||
if (HasErrors)
|
if (HasErrors)
|
||||||
return false;
|
return false;
|
||||||
ct.PartWarehouse.Remove(dbObject);
|
ct.PartWarehouse.Remove(dbObject);
|
||||||
@@ -240,7 +238,6 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Any form customizations to validate?
|
//Any form customizations to validate?
|
||||||
var FormCustomization = await ct.FormCustom.AsNoTracking().SingleOrDefaultAsync(x => x.FormKey == AyaType.PartWarehouse.ToString());
|
var FormCustomization = await ct.FormCustom.AsNoTracking().SingleOrDefaultAsync(x => x.FormKey == AyaType.PartWarehouse.ToString());
|
||||||
if (FormCustomization != null)
|
if (FormCustomization != null)
|
||||||
@@ -253,18 +250,26 @@ namespace AyaNova.Biz
|
|||||||
//validate custom fields
|
//validate custom fields
|
||||||
CustomFieldsValidator.Validate(this, FormCustomization, proposedObj.CustomFields);
|
CustomFieldsValidator.Validate(this, FormCustomization, proposedObj.CustomFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ValidateCanDelete(PartWarehouse inObj)
|
private async Task ValidateCanDelete(PartWarehouse inObj)
|
||||||
{
|
{
|
||||||
//whatever needs to be check to delete this object
|
|
||||||
|
|
||||||
//Can't delete the default warehouse
|
//Can't delete the default warehouse
|
||||||
if (inObj.Id == 1)
|
if (inObj.Id == 1)
|
||||||
{
|
{
|
||||||
AddError(ApiErrorCode.INVALID_OPERATION, "generalerror", "Default part warehouse can not be deleted");
|
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?
|
||||||
|
if (await ct.PartInventory.AnyAsync(m => m.PartWarehouseId == inObj.Id))
|
||||||
|
{
|
||||||
|
AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", "LT:PartInventory");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user