public MemberViewModel Build(Member member, Object @object, int? objectId = null)
        {
            IEnumerable<RelationViewModel> relations = null;
              PropertyViewModel property = null;

              if (member.RelationClassId != null)
              {
            if (@object == null && objectId == null)
              relations = new RelationViewModel[] { };

            else if (@object == null && objectId != null)
              relations = new RelationViewModel[] { new RelationViewModel() { PrimaryId = (int)objectId } };

            else relations = this.handler.Storage.GetRepository<IRelationRepository>().FilteredByMemberIdAndForeignId(member.Id, @object.Id).Select(
              r => new RelationViewModelBuilder(this.handler).Build(r)
            );
              }

              else if (member.PropertyDataTypeId != null)
              {
            if (@object == null)
              property = new PropertyViewModelBuilder(this.handler).Build(
            new Property() { ObjectId = @object == null ? (int?)null : @object.Id  }
              );

            else
            {
              Property p = this.handler.Storage.GetRepository<IPropertyRepository>().WithObjectIdAndMemberId(@object.Id, member.Id);

              property = new PropertyViewModelBuilder(this.handler).Build(
            p == null ? new Property() { ObjectId = @object == null ? (int?)null : @object.Id } : p
              );
            }
              }

              return new MemberViewModel()
              {
            Id = member.Id,
            RelationClass = member.RelationClassId == null ? null : new ClassViewModelBuilder(this.handler).Build(
              this.handler.Storage.GetRepository<IClassRepository>().WithKey((int)member.RelationClassId)
            ),
            IsRelationSingleParent = member.IsRelationSingleParent == true,
            Relations = relations,
            PropertyDataType = member.PropertyDataTypeId == null ? null : new DataTypeViewModelBuilder(this.handler).Build(
              this.handler.Storage.GetRepository<IDataTypeRepository>().WithKey((int)member.PropertyDataTypeId)
            ),
            Property = property,
            Name = member.Name,
            Position = member.Position
              };
        }
        public Member Map(CreateOrEditViewModel createOrEdit)
        {
            Member member = new Member();

              if (createOrEdit.Id != null)
            member = this.handler.Storage.GetRepository<IMemberRepository>().WithKey((int)createOrEdit.Id);

              else member.ClassId = createOrEdit.ClassId;

              member.TabId = createOrEdit.TabId;
              member.Code = createOrEdit.Code;
              member.Name = createOrEdit.Name;
              member.DisplayInList = createOrEdit.DisplayInList ? true : (bool?)null;
              member.Position = createOrEdit.Position;
              member.RelationClassId = createOrEdit.RelationClassId;
              member.IsRelationSingleParent = createOrEdit.IsRelationSingleParent ? true : (bool?)null;
              member.PropertyDataTypeId = createOrEdit.PropertyDataTypeId;
              return member;
        }