コード例 #1
0
        public static dataModel.Organization ToDataModel(this coreModel.Organization organization)
        {
            if (organization == null)
            {
                throw new ArgumentNullException("organization");
            }

            var retVal = new dataModel.Organization();

            retVal.InjectFrom(organization);

            if (organization.Phones != null)
            {
                retVal.Phones = new ObservableCollection <dataModel.Phone>(organization.Phones.Select(x => new dataModel.Phone
                {
                    Number   = x,
                    MemberId = organization.Id
                }));
            }

            if (organization.Emails != null)
            {
                retVal.Emails = new ObservableCollection <dataModel.Email>(organization.Emails.Select(x => new dataModel.Email
                {
                    Address  = x,
                    MemberId = organization.Id
                }));
            }

            if (organization.Addresses != null)
            {
                retVal.Addresses = new ObservableCollection <dataModel.Address>(organization.Addresses.Select(x => x.ToDataModel()));
                foreach (var address in retVal.Addresses)
                {
                    address.MemberId = organization.Id;
                }
            }

            if (organization.Notes != null)
            {
                retVal.Notes = new ObservableCollection <dataModel.Note>(organization.Notes.Select(x => x.ToDataModel()));
                foreach (var note in retVal.Notes)
                {
                    note.MemberId = organization.Id;
                }
            }

            if (organization.ParentId != null)
            {
                retVal.MemberRelations = new ObservableCollection <dataModel.MemberRelation>();
                var memberRelation = new dataModel.MemberRelation
                {
                    AncestorId       = organization.ParentId,
                    DescendantId     = organization.Id,
                    AncestorSequence = 1
                };
                retVal.MemberRelations.Add(memberRelation);
            }
            return(retVal);
        }
コード例 #2
0
        public static dataModel.Contact ToDataModel(this coreModel.Contact contact, PrimaryKeyResolvingMap pkMap)
        {
            if (contact == null)
            {
                throw new ArgumentNullException("contact");
            }

            var retVal = new dataModel.Contact();

            contact.ToDataModel(retVal);

            if (retVal.Name == null)
            {
                retVal.Name = retVal.FullName;
            }

            pkMap.AddPair(contact, retVal);

            if (contact.Organizations != null)
            {
                retVal.MemberRelations = new ObservableCollection <dataModel.MemberRelation>();
                foreach (var organization in contact.Organizations)
                {
                    var memberRelation = new dataModel.MemberRelation
                    {
                        AncestorId       = organization,
                        AncestorSequence = 1,
                        DescendantId     = retVal.Id,
                    };
                    retVal.MemberRelations.Add(memberRelation);
                }
            }
            return((dataModel.Contact)retVal);
        }
コード例 #3
0
        public static dataModel.Organization ToDataModel(this coreModel.Organization organization, PrimaryKeyResolvingMap pkMap)
        {
            if (organization == null)
            {
                throw new ArgumentNullException("organization");
            }

            var retVal = new dataModel.Organization();

            organization.ToDataModel(retVal);

            pkMap.AddPair(organization, retVal);

            if (organization.ParentId != null)
            {
                retVal.MemberRelations = new ObservableCollection <dataModel.MemberRelation>();
                var memberRelation = new dataModel.MemberRelation
                {
                    AncestorId       = organization.ParentId,
                    DescendantId     = organization.Id,
                    AncestorSequence = 1
                };
                retVal.MemberRelations.Add(memberRelation);
            }
            return(retVal);
        }
コード例 #4
0
        public static dataModel.Contact ToDataModel(this coreModel.Contact contact, PrimaryKeyResolvingMap pkMap)
        {
            if (contact == null)
                throw new ArgumentNullException("contact");

            var retVal = new dataModel.Contact();

            contact.ToDataModel(retVal);

            if (retVal.Name == null)
            {
                retVal.Name = retVal.FullName;
            }

            pkMap.AddPair(contact, retVal);

            if (contact.Organizations != null)
            {
                retVal.MemberRelations = new ObservableCollection<dataModel.MemberRelation>();
                foreach (var organization in contact.Organizations)
                {
                    var memberRelation = new dataModel.MemberRelation
                    {
                        AncestorId = organization,
                        AncestorSequence = 1,
                        DescendantId = retVal.Id,
                    };
                    retVal.MemberRelations.Add(memberRelation);
                }
            }
            return (dataModel.Contact)retVal;
        }
コード例 #5
0
        public static dataModel.Contact ToDataModel(this coreModel.Contact contact)
        {
            if (contact == null)
                throw new ArgumentNullException("contact");

            var retVal = new dataModel.Contact();

            retVal.InjectFrom(contact);

            if (contact.Phones != null)
            {
                retVal.Phones = new ObservableCollection<dataModel.Phone>(contact.Phones.Select(x => new dataModel.Phone
                {
                    Number = x,
                    MemberId = contact.Id
                }));
            }

            if (contact.Emails != null)
            {
                retVal.Emails = new ObservableCollection<dataModel.Email>(contact.Emails.Select(x => new dataModel.Email
                {
                    Address = x,
                    MemberId = contact.Id
                }));
            }

            if (contact.Addresses != null)
            {
                retVal.Addresses = new ObservableCollection<dataModel.Address>(contact.Addresses.Select(x => x.ToDataModel()));
                foreach (var address in retVal.Addresses)
                {
                    address.MemberId = contact.Id;
                }
            }

            if (contact.Notes != null)
            {
                retVal.Notes = new ObservableCollection<dataModel.Note>(contact.Notes.Select(x => x.ToDataModel()));
                foreach (var note in retVal.Notes)
                {
                    note.MemberId = contact.Id;
                }
            }

            if (contact.Organizations != null)
            {
                retVal.MemberRelations = new ObservableCollection<dataModel.MemberRelation>();
                foreach (var organization in contact.Organizations)
                {
                    var memberRelation = new dataModel.MemberRelation
                    {
                        AncestorId = organization,
                        AncestorSequence = 1,
                        DescendantId = retVal.Id
                    };
                    retVal.MemberRelations.Add(memberRelation);
                }
            }
            return retVal;
        }
コード例 #6
0
        public static dataModel.Contact ToDataModel(this coreModel.Contact contact, PrimaryKeyResolvingMap pkMap)
        {
            if (contact == null)
            {
                throw new ArgumentNullException("contact");
            }

            var retVal = new dataModel.Contact();

            pkMap.AddPair(contact, retVal);

            retVal.InjectFrom(contact);

            if (contact.Phones != null)
            {
                retVal.Phones = new ObservableCollection <dataModel.Phone>(contact.Phones.Select(x => new dataModel.Phone
                {
                    Number   = x,
                    MemberId = contact.Id
                }));
            }

            if (contact.Emails != null)
            {
                retVal.Emails = new ObservableCollection <dataModel.Email>(contact.Emails.Select(x => new dataModel.Email
                {
                    Address  = x,
                    MemberId = contact.Id
                }));
            }

            if (contact.Addresses != null)
            {
                retVal.Addresses = new ObservableCollection <dataModel.Address>(contact.Addresses.Select(x => x.ToDataModel()));
                foreach (var address in retVal.Addresses)
                {
                    address.MemberId = contact.Id;
                }
            }

            if (contact.Notes != null)
            {
                retVal.Notes = new ObservableCollection <dataModel.Note>(contact.Notes.Select(x => x.ToDataModel()));
                foreach (var note in retVal.Notes)
                {
                    note.MemberId = contact.Id;
                }
            }

            if (contact.Organizations != null)
            {
                retVal.MemberRelations = new ObservableCollection <dataModel.MemberRelation>();
                foreach (var organization in contact.Organizations)
                {
                    var memberRelation = new dataModel.MemberRelation
                    {
                        AncestorId       = organization,
                        AncestorSequence = 1,
                        DescendantId     = retVal.Id
                    };
                    retVal.MemberRelations.Add(memberRelation);
                }
            }
            return(retVal);
        }
コード例 #7
0
        public static dataModel.Organization ToDataModel(this coreModel.Organization organization, PrimaryKeyResolvingMap pkMap)
        {
            if (organization == null)
                throw new ArgumentNullException("organization");

            var retVal = new dataModel.Organization();
            pkMap.AddPair(organization, retVal);

            retVal.InjectFrom(organization);

            if (organization.Phones != null)
            {
                retVal.Phones = new ObservableCollection<dataModel.Phone>(organization.Phones.Select(x => new dataModel.Phone
                {
                    Number = x,
                    MemberId = organization.Id
                }));
            }

            if (organization.Emails != null)
            {
                retVal.Emails = new ObservableCollection<dataModel.Email>(organization.Emails.Select(x => new dataModel.Email
                {
                    Address = x,
                    MemberId = organization.Id
                }));
            }

            if (organization.Addresses != null)
            {
                retVal.Addresses = new ObservableCollection<dataModel.Address>(organization.Addresses.Select(x => x.ToDataModel()));
                foreach (var address in retVal.Addresses)
                {
                    address.MemberId = organization.Id;
                }
            }

            if (organization.Notes != null)
            {
                retVal.Notes = new ObservableCollection<dataModel.Note>(organization.Notes.Select(x => x.ToDataModel()));
                foreach (var note in retVal.Notes)
                {
                    note.MemberId = organization.Id;
                }
            }

            if (organization.ParentId != null)
            {
                retVal.MemberRelations = new ObservableCollection<dataModel.MemberRelation>();
                var memberRelation = new dataModel.MemberRelation
                {
                    AncestorId = organization.ParentId,
                    DescendantId = organization.Id,
                    AncestorSequence = 1

                };
                retVal.MemberRelations.Add(memberRelation);
            }
            return retVal;
        }