Пример #1
0
        public void Register(ICitizen citizen)
        {
            if (citizen.VatId == null || CitizenRegistryHelper.FindCitizenById(citizens, citizenCount, citizen.VatId) == null)
            {
                if (String.IsNullOrWhiteSpace(citizen.VatId))
                {
                    int    birthNumber;
                    string id;

                    do
                    {
                        birthNumber = CitizenRegistryHelper.GetBirthNumber(citizen.Gender);
                        id          = CitizenRegistryHelper.GenerateVatId(citizen.BirthDate, birthNumber, citizen.Gender);
                    } while (CitizenRegistryHelper.FindCitizenById(citizens, citizenCount, id) != null);
                    citizen.VatId = id;
                }
                if (citizenCount == citizens.Length)
                {
                    Array.Resize(ref citizens, citizens.Length * 2);
                }
                citizens[citizenCount] = citizen.Clone() as Citizen;
                citizenCount++;
                lastRegistrationTime = SystemDateTime.Now();
            }
            else
            {
                throw new InvalidOperationException();
            }
        }
Пример #2
0
 public ICitizen this[string id]
 {
     get
     {
         if (id == null)
         {
             throw new ArgumentNullException("id");
         }
         else
         {
             return(CitizenRegistryHelper.FindCitizenById(citizens, citizenCount, id));
         }
     }
 }