示例#1
0
        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 Database.Entities.Person CreateEntity()
        {
            var name    = Name.CreateEntity();
            var address = Address?.CreateEntity();

            var entity = new Database.Entities.Person()
            {
                Name      = name,
                Address   = address,
                Height    = Height,
                Weight    = Weight,
                HairColor = HairColor,
                EyeColor  = EyeColor,
                BirthDate = BirthDate
            };

            return(entity);
        }
        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);
            }
        }
示例#4
0
 public DeleteEvent(Database.Entities.Person person)
 {
     Person = person;
 }
示例#5
0
 public CreateEvent(Database.Entities.Person person)
 {
     Person = person;
 }