Exemplo n.º 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;
            }
        }
Exemplo n.º 2
0
 private static void RaiseErrorIfNoObservationFound(Observation[] tmp)
 {
     if (tmp == null || tmp.Length == 0)
     {
         string errorMessage = "no observations found";
         throw new BusinessException(errorMessage);
     }
 }
Exemplo n.º 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");
            }
        }
Exemplo n.º 4
0
 public int GetIdFor(Observation observation)
 {
     string key = MakeSurrogateKey(observation.Country, observation.HouseholdId, observation.PersonId);
     return GetIdForKey(key);
 }