public PersonViewModel(int id, Database.Entities.Person entity) : base(id) { entity.ArgumentNullCheck(nameof(entity)); Height = entity.Height; Weight = entity.Weight; HairColor = entity.HairColor; EyeColor = entity.EyeColor; BirthDate = entity.BirthDate; Name = new NameViewModel(entity.NameId, entity.Name); if (entity.AddressId.HasValue) { Address = new AddressViewModel(entity.AddressId.Value, entity.Address); } }
public virtual void UpdateEntity(Database.Entities.Person entity) { entity.ArgumentNullCheck(nameof(entity)); entity.Height = Height; entity.Weight = Weight; entity.HairColor = HairColor; entity.EyeColor = EyeColor; entity.BirthDate = BirthDate; Name.UpdateEntity(entity.Name); if (Address == null) { entity.Address = null; } else { Address?.UpdateEntity(entity.Address); } }