private TcpMessage HandleMultiRelationQuery(TcpConnectedHost host, TcpMessage message) { if (!message.HasType(TcpRequestType.MultiRelationQuery)) { return(null); } if (!IsAuthenticated(host)) { throw AuthException.NotLoggedIn(); } var request = new ParamTcpMessage(message); var response = new ObjectTcpMessage <DbRelation>(TcpRequestType.List); if (request.HasParam("from_id")) { var fromId = request.GetParamAsNullableInt("from_id"); var items = _dataService.GetRelations(fromId); response.Add(items); return(response); } return(TcpMessage.Error("Missing or badly formatted query parameters")); }
public IEnumerable GetChildren(TreePath treePath) { if (treePath.IsEmpty()) { return(_dataService.GetRelations(null)); } if (treePath.LastNode is DbItem) { var item = treePath.LastNode as DbItem; return(_dataService.GetRelations(item.Id)); } else if (treePath.LastNode is DbRelation) { var relation = treePath.LastNode as DbRelation; if (relation.ToId != null) { return new[] { _dataService.GetItem(relation.ToId.Value) } } ; } return(null); }
public static void Remove <T>(T obj, int?fromId, DataServiceBase dataService) { var proxy = obj as IProxy; if (proxy == null) { return; } var relations = dataService.GetRelations(fromId); foreach (var relation in relations) { if (relation.ToId == proxy.SDBId) { dataService.Delete(relation); } } }
public override ICollection <DbRelation> GetRelations(int?fromId) { return(_dataService.GetRelations(fromId)); }