Exemplo n.º 1
0
        private static PersonName CreatePersonName(Person person, PersonNameType nameType, string name, DateTime today)
        {
            if (string.IsNullOrWhiteSpace(name))
                return null;

            PersonName personName = new PersonName();
            personName.Name = name;
            personName.PersonNameType = nameType;
            personName.Person = person;
            personName.EffectiveDate = today;

            Context.PersonNames.AddObject(personName);

            return personName;
        }
Exemplo n.º 2
0
 private static PersonName GetPersonNameByTypeEntity(Person person, PersonNameType type)
 {
     var personName = person.PersonNames.SingleOrDefault(entity => entity.PersonNameTypeId == type.Id && entity.EndDate == null);
     return personName;
 }
Exemplo n.º 3
0
        public static void CreateOrUpdatePersonNames(Person person, PersonNameType type, string name, DateTime today)
        {
            PersonName personName = GetPersonNameByTypeEntity(person, type);

            if (personName == null || name != personName.Name)
            {
                if (personName != null)
                    personName.EndDate = today;
                CreatePersonName(person, type, name, today);
            }
        }