Beispiel #1
0
        public Guid[] Search(CprBroker.Schemas.Part.SoegInputType1 searchCriteria)
        {
            Guid[] ret = null;
            using (var dataContext = new PartDataContext())
            {
                int firstResults = 0;
                int.TryParse(searchCriteria.FoersteResultatReference, out firstResults);

                int maxResults = 0;
                int.TryParse(searchCriteria.MaksimalAntalKvantitet, out maxResults);
                if (maxResults <= 0)
                {
                    maxResults = 1000;
                }

                var result = PersonRegistration.GetUuidsByCriteria(dataContext, searchCriteria.SoegObjekt, firstResults, maxResults);
                ret = result.ToArray();
            }
            // TODO: filter by effect date
            return(ret);
        }
Beispiel #2
0
        public static Expression <Func <PersonRegistration, bool> > CreateWhereExpression(PartDataContext dataContext, CprBroker.Schemas.Part.SoegInputType1 searchCriteria)
        {
            var pred = PredicateBuilder.True <Data.Part.PersonRegistration>();

            if (searchCriteria.SoegObjekt != null)
            {
                if (!string.IsNullOrEmpty(searchCriteria.SoegObjekt.UUID))
                {
                    var personUuid = new Guid(searchCriteria.SoegObjekt.UUID);
                    pred = pred.And(p => p.UUID == personUuid);
                }
                // Search by cpr number
                if (!string.IsNullOrEmpty(searchCriteria.SoegObjekt.BrugervendtNoegleTekst))
                {
                    pred = pred.And(pr => pr.Person.UserInterfaceKeyText == searchCriteria.SoegObjekt.BrugervendtNoegleTekst);
                }
                if (searchCriteria.SoegObjekt.SoegAttributListe != null)
                {
                    if (searchCriteria.SoegObjekt.SoegAttributListe.SoegEgenskab != null)
                    {
                        foreach (var prop in searchCriteria.SoegObjekt.SoegAttributListe.SoegEgenskab)
                        {
                            if (prop != null && prop.NavnStruktur != null)
                            {
                                if (prop.NavnStruktur.PersonNameStructure != null)
                                {
                                    // Search by name
                                    var name = prop.NavnStruktur.PersonNameStructure;
                                    if (!name.IsEmpty)
                                    {
                                        // TODO: Test name lookup after new struture (multiple attribuutes)

                                        /*
                                         * var cprNamePred = PredicateBuilder.True<Data.Part.PersonRegistration>();
                                         * if (!string.IsNullOrEmpty(name.PersonGivenName))
                                         * {
                                         *  cprNamePred = cprNamePred.And((pt) => pt.PersonAttributes.Where(attr => attr.PersonProperties != null && attr.PersonProperties.PersonName.FirstName == name.PersonGivenName).FirstOrDefault() != null);
                                         * }
                                         * if (!string.IsNullOrEmpty(name.PersonMiddleName))
                                         * {
                                         *  cprNamePred = cprNamePred.And((pt) => pt.PersonAttributes.Where(attr => attr.PersonProperties != null && attr.PersonProperties.PersonName.MiddleName == name.PersonMiddleName).FirstOrDefault() != null);
                                         * }
                                         * if (!string.IsNullOrEmpty(name.PersonSurnameName))
                                         * {
                                         *  cprNamePred = cprNamePred.And((pt) => pt.PersonAttributes.Where(attr => attr.PersonProperties != null && attr.PersonProperties.PersonName.LastName == name.PersonSurnameName).FirstOrDefault() != null);
                                         * }
                                         * pred = pred.And(cprNamePred);
                                         */
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(pred);
        }