public ActionResult Get(string cpr) { int GetBirthdayYear(rootGctpSystemServiceCprDataRolleTableRow m) => Int32.Parse(GetAttr(m, "PNR_FOEDDATO").Substring(4, 2)); int GetCurrentYear() => Int32.Parse(DateTime.Now.ToString("yy")); int GetYearDifference(rootGctpSystemServiceCprDataRolleTableRow m) => GetCurrentYear() - GetBirthdayYear(m); if (!Validate(cpr)) { return(BadRequest("Invalid CPR!")); } log.Info("Attempting familie lookup on: " + Hide(cpr)); GCTPLookupRequestType request = new GCTPLookupRequestType(); request.InvocationContext = GetInvocationContext(); request.gctpMessage = $"<Gctp v=\"1.0\"><System r=\"CprSoeg\"><Service r=\"Familie\"><CprServiceHeader r=\"Familie\"><Key><Field r=\"PNR\" v=\"{cpr}\"/></Key></CprServiceHeader></Service></System></Gctp>"; CprLookupServicePortTypeClient lookupService = new CprLookupServicePortTypeClient(Configuration["OmFamilieService:serviceUrl"], Configuration["OmFamilieService:certPath"], Configuration["OmFamilieService:certPassword"]); callGctpServiceResponse response = lookupService.callGctpServiceAsync(request).Result; XmlSerializer serializer = new XmlSerializer(typeof(root)); StringReader rdr = new StringReader(response.callGCTPCheckServiceResponse.result); root gctpResponse = (root)serializer.Deserialize(rdr); rootGctpSystemServiceCprDataRolleTableRow[] members = gctpResponse.Gctp.System.Service.CprData.Rolle.Table.Row; // Filter only underaged kids members = members.Where(m => GetYearDifference(m) > 0 && GetYearDifference(m) < 18).ToArray(); var result = members.Where(m => GetAttr(m, "FAMMRK").Equals("Barn")).Select(m => new { name = GetAttr(m, "ADRNVN"), cpr = GetAttr(m, "PNR_FOEDDATO") }).ToArray(); return(Ok(result)); }
private static System.ServiceModel.EndpointAddress GetDefaultEndpointAddress() { return(CprLookupServicePortTypeClient.GetEndpointAddress(EndpointConfiguration.CprServicePort)); }
private static System.ServiceModel.Channels.Binding GetDefaultBinding() { return(CprLookupServicePortTypeClient.GetBindingForEndpoint(EndpointConfiguration.CprServicePort)); }
public CprLookupServicePortTypeClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) : base(CprLookupServicePortTypeClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress) { this.Endpoint.Name = endpointConfiguration.ToString(); ConfigureEndpoint(this.Endpoint, this.ClientCredentials); }
public CprLookupServicePortTypeClient(EndpointConfiguration endpointConfiguration) : base(CprLookupServicePortTypeClient.GetBindingForEndpoint(endpointConfiguration), CprLookupServicePortTypeClient.GetEndpointAddress(endpointConfiguration)) { this.Endpoint.Name = endpointConfiguration.ToString(); ConfigureEndpoint(this.Endpoint, this.ClientCredentials); }
public CprLookupServicePortTypeClient() : base(CprLookupServicePortTypeClient.GetDefaultBinding(), CprLookupServicePortTypeClient.GetDefaultEndpointAddress()) { this.Endpoint.Name = EndpointConfiguration.CprServicePort.ToString(); ConfigureEndpoint(this.Endpoint, this.ClientCredentials); }