Exemple #1
0
        public Person CreateInstance(Observation observation)
        {
            int id = idMap.GetIdFor(observation);

            if (peopleCache.ContainsKey(id))
            {
                return peopleCache[id];
            }
            else
            {
                string country = observation.Country;
                string personId = observation.PersonId;
                Person person = new Person(country, personId);
                peopleCache[id] = person;
                return person;
            }
        }
Exemple #2
0
 private static void RaiseErrorIfNoObservationFound(Observation[] tmp)
 {
     if (tmp == null || tmp.Length == 0)
     {
         string errorMessage = "no observations found";
         throw new BusinessException(errorMessage);
     }
 }
Exemple #3
0
        private static void ValidateObservation(Observation observation)
        {
            if (string.IsNullOrEmpty(observation.Country))
            {
                throw new BusinessException("country field in observation cannot be null");
            }

            if (string.IsNullOrEmpty(observation.HouseholdId))
            {
                throw new BusinessException("householdId field in observation cannot be null");
            }

            if (string.IsNullOrEmpty(observation.PersonId))
            {
                throw new BusinessException("personId field in observation cannot be null");
            }
        }
Exemple #4
0
 public int GetIdFor(Observation observation)
 {
     string key = MakeSurrogateKey(observation.Country, observation.HouseholdId, observation.PersonId);
     return GetIdForKey(key);
 }