iipRequestAddChild method
void
iipRequestAddChild(
- int callback,
- int parentId,
- int childId
)
Implementation
void iipRequestAddChild(int callback, int parentId, int childId) {
Warehouse.getById(parentId).then((parent) {
if (parent == null) {
sendError(ErrorType.Management, callback,
ExceptionCode.ResourceNotFound.index);
return;
}
Warehouse.getById(childId).then((child) {
if (child == null) {
sendError(ErrorType.Management, callback,
ExceptionCode.ResourceNotFound.index);
return;
}
if (parent.instance
?.applicable(_session as Session, ActionType.AddChild, null) !=
Ruling.Allowed) {
sendError(ErrorType.Management, callback,
ExceptionCode.AddChildDenied.index);
return;
}
if (child.instance
?.applicable(_session as Session, ActionType.AddParent, null) !=
Ruling.Allowed) {
sendError(ErrorType.Management, callback,
ExceptionCode.AddParentDenied.index);
return;
}
parent.instance?.children.add(child);
sendReply(IIPPacketAction.AddChild, callback).done();
//child.instance.Parents
});
});
}