public static CompanyResult Build(PerfectView.RelationGetResponse response, PerfectView.RelationGetParentRelationshipsResponse parentResponse, PerfectView.RelationGetChildRelationshipsResponse childResponse) { if(response.Body.RelationGetResult.Relation != null) { return new CompanyResult { Name = GetValue(response.Body.RelationGetResult.Relation, RelationField.Organisatienaam), Id = parentResponse.Body.RelationGetParentRelationshipsResult.Relationships != null && parentResponse.Body.RelationGetParentRelationshipsResult.Relationships.Any() ? parentResponse.Body.RelationGetParentRelationshipsResult.Relationships[0].Id : Guid.Empty, Code = GetValue(response.Body.RelationGetResult.Relation, RelationField.Debiteurnummer), Adres = string.Join(" ", GetValue(response.Body.RelationGetResult.Relation, RelationField.Bezoekadresstraat), GetValue(response.Body.RelationGetResult.Relation, RelationField.Bezoekadresnummer), GetValue(response.Body.RelationGetResult.Relation, RelationField.Bezoekadrestoevoeging)), Postcode = GetValue(response.Body.RelationGetResult.Relation, RelationField.Bezoekadrespostcode), Plaats = GetValue(response.Body.RelationGetResult.Relation, RelationField.Bezoekadresplaats), Emailadres = GetValue(response.Body.RelationGetResult.Relation, RelationField.Algemeenemailadres), Telefoon = GetValue(response.Body.RelationGetResult.Relation, RelationField.Algemeentelefoonnummer), Contactpersoon = childResponse.Body.RelationGetChildRelationshipsResult.Relationships != null && childResponse.Body.RelationGetChildRelationshipsResult.Relationships.Any() ? childResponse.Body.RelationGetChildRelationshipsResult.Relationships[0].DisplayName : "", ContactpersoonId = childResponse.Body.RelationGetChildRelationshipsResult.Relationships != null && childResponse.Body.RelationGetChildRelationshipsResult.Relationships.Any() ? childResponse.Body.RelationGetChildRelationshipsResult.Relationships[0].Id : (Guid?)null, Notities = GetValue(response.Body.RelationGetResult.Relation, RelationField.Extrainfo), }; } return null; }
public static IEnumerable<CompanySearchResult> Build(PerfectView.RelationSearchByName_V2Response response) { foreach(var entry in response.Body.RelationSearchByName_V2Result.Relations.Where(e => e.EntityTypeId == _customerType)) { yield return new CompanySearchResult { Name = entry.DisplayName, Id = entry.Id.ToString() }; } }