Ejemplo n.º 1
0
 public Arena.Services.Contracts.Person FromArena(Arena.Core.Person arena)
 {
     Arena.Services.Contracts.Person person = new Arena.Services.Contracts.Person();
     if (this.ShouldShow(arena, "PersonID"))
     {
         person.PersonID = new int?(arena.PersonID);
     }
     if (this.ShouldShow(arena, "PersonGUID"))
     {
         person.PersonGUID = new Guid?(arena.PersonGUID);
     }
     if (this.ShouldShow(arena, "PersonLink"))
     {
         Guid personGUID = arena.PersonGUID;
         person.PersonLink = string.Format("person/{0}", personGUID.ToString());
     }
     if (this.ShouldShow(arena, "OrganizationID"))
     {
         person.OrganizationID = new int?(arena.OrganizationID);
     }
     if (arena.Campus != null && this.ShouldShow(arena, "CampusID"))
     {
         person.CampusID = new int?(arena.Campus.CampusId);
     }
     if (arena.Campus != null && this.ShouldShow(arena, "CampusName"))
     {
         person.CampusName = arena.Campus.Name;
     }
     if (this.ShouldShow(arena, "TitleID"))
     {
         person.TitleID = new int?(arena.Title.LookupID);
     }
     if (this.ShouldShow(arena, "TitleValue"))
     {
         person.TitleValue = arena.Title.ToString();
     }
     if (this.ShouldShow(arena, "SuffixID"))
     {
         person.SuffixID = new int?(arena.Suffix.LookupID);
     }
     if (this.ShouldShow(arena, "SuffixValue"))
     {
         person.SuffixValue = arena.Suffix.ToString();
     }
     if (this.ShouldShow(arena, "NickName"))
     {
         person.NickName = arena.NickName;
     }
     if (this.ShouldShow(arena, "FirstName"))
     {
         person.FirstName = arena.FirstName;
     }
     if (this.ShouldShow(arena, "MiddleName"))
     {
         person.MiddleName = arena.MiddleName;
     }
     if (this.ShouldShow(arena, "LastName"))
     {
         person.LastName = arena.LastName;
     }
     if (this.ShouldShow(arena, "FullName"))
     {
         person.FullName = arena.FullName;
     }
     if (this.ShouldShow(arena, "FamilyID"))
     {
         person.FamilyID = new int?(arena.FamilyId);
     }
     if (this.ShouldShow(arena, "FamilyName"))
     {
         person.FamilyName = arena.Family().FamilyName;
     }
     if (this.ShouldShow(arena, "FamilyLink"))
     {
         int? familyID = person.FamilyID;
         person.FamilyLink = string.Format("family/{0}", familyID.ToString());
     }
     if (this.ShouldShow(arena, "Age"))
     {
         person.Age = new int?(arena.Age);
     }
     if (this.ShouldShow(arena, "Gender"))
     {
         person.Gender = arena.Gender.ToString();
     }
     if (this.ShouldShow(arena, "Notes"))
     {
         person.Notes = arena.Notes;
     }
     if (this.ShouldShow(arena, "MedicalInformation"))
     {
         person.MedicalInformation = arena.MedicalInformation;
     }
     if (this.ShouldShow(arena, "EnvelopeNumber"))
     {
         person.EnvelopeNumber = new int?(arena.EnvelopeNumber);
     }
     if (this.ShouldShow(arena, "IncludeOnEnvelope"))
     {
         person.IncludeOnEnvelope = new bool?(arena.IncludeOnEnvelope);
     }
     if (this.ShouldShow(arena, "MaritalStatusID"))
     {
         person.MaritalStatusID = new int?(arena.MaritalStatus.LookupID);
     }
     if (this.ShouldShow(arena, "MaritalStatusValue"))
     {
         person.MaritalStatusValue = arena.MaritalStatus.ToString();
     }
     if (this.ShouldShow(arena, "AnniversaryDate"))
     {
         person.AnniversaryDate = new DateTime?(arena.AnniversaryDate);
     }
     if (this.ShouldShow(arena, "MemberStatusID"))
     {
         person.MemberStatusID = new int?(arena.MemberStatus.LookupID);
     }
     if (this.ShouldShow(arena, "MemberStatusValue"))
     {
         person.MemberStatusValue = arena.MemberStatus.ToString();
     }
     if (this.ShouldShow(arena, "RecordStatusID"))
     {
         person.RecordStatusID = new int?(Convert.ToInt32(arena.RecordStatus));
     }
     if (this.ShouldShow(arena, "RecordStatusValue"))
     {
         person.RecordStatusValue = arena.RecordStatus.ToString();
     }
     if (this.ShouldShow(arena, "InactiveReasonID"))
     {
         person.InactiveReasonID = new int?(arena.InactiveReason.LookupID);
     }
     if (this.ShouldShow(arena, "InactiveReasonValue"))
     {
         person.InactiveReasonValue = arena.InactiveReason.ToString();
     }
     if (this.ShouldShow(arena, "ActiveMeter"))
     {
         person.ActiveMeter = new int?(arena.ActiveMeter);
     }
     if (this.ShouldShow(arena, "ContributeIndividually"))
     {
         person.ContributeIndividually = new bool?(arena.ContributeIndividually);
     }
     if (this.ShouldShow(arena, "PrintStatement"))
     {
         person.PrintStatement = new bool?(arena.PrintStatement);
     }
     if (this.ShouldShow(arena, "EmailStatement"))
     {
         person.EmailStatement = new bool?(arena.EmailStatement);
     }
     if (this.ShouldShow(arena, "RegionName"))
     {
         person.RegionName = arena.RegionName;
     }
     if (this.ShouldShow(arena, "BlobID"))
     {
         person.BlobID = new int?(arena.BlobID);
     }
     if (this.ShouldShow(arena, "BlobLink"))
     {
         if (arena.BlobID > 0)
         {
             Guid gUID = arena.Blob.GUID;
             person.BlobLink = base.BuildBlobUrl(gUID.ToString(), -1, Gender.Unknown);
         }
     }
     if (this.ShouldShow(arena, "GivingUnitID"))
     {
         person.GivingUnitID = arena.GivingUnitID;
     }
     if (this.ShouldShow(arena, "ForeignKey"))
     {
         person.ForeignKey = new int?(arena.ForeignKey);
     }
     if (this.ShouldShow(arena, "ForeignKey2"))
     {
         person.ForeignKey2 = new int?(arena.ForeignKey2);
     }
     if (this.ShouldShow(arena, "Addresses"))
     {
         foreach (Arena.Core.PersonAddress arenaAddress in arena.Addresses)
         {
             Address address = new Address()
             {
                 AddressID = arenaAddress.AddressID,
                 StreetLine1 = arenaAddress.Address.StreetLine1,
                 StreetLine2 = arenaAddress.Address.StreetLine2,
                 City = arenaAddress.Address.City,
                 State = arenaAddress.Address.State,
                 PostalCode = arenaAddress.Address.PostalCode,
                 Country = arenaAddress.Address.Country
             };
             if (arenaAddress.AddressType != null && arenaAddress.AddressType.LookupID != -1)
             {
                 address.AddressTypeValue = arenaAddress.AddressType.Value;
                 address.AddressTypeID = arenaAddress.AddressType.LookupID;
             }
             if (arenaAddress.Address.Latitude != 0)
             {
                 address.Latitude = new double?(arenaAddress.Address.Latitude);
             }
             if (arenaAddress.Address.Longitude != 0)
             {
                 address.Longitude = new double?(arenaAddress.Address.Longitude);
             }
             address.Primary = arenaAddress.Primary;
             person.AddAddress(address);
         }
     }
     if (this.ShouldShow(arena, "Phones"))
     {
         foreach (Arena.Core.PersonPhone arenaPhone in arena.Phones)
         {
             Arena.Services.Contracts.Phone phone = new Arena.Services.Contracts.Phone()
             {
                 PhoneTypeID = arenaPhone.PhoneType.LookupID,
                 PhoneTypeValue = arenaPhone.PhoneType.Value,
                 Unlisted = arenaPhone.Unlisted,
                 SMSEnabled = arenaPhone.SMSEnabled,
                 Extension = arenaPhone.Extension,
                 Number = arenaPhone.Number
             };
             person.AddPhone(phone);
         }
     }
     if (this.ShouldShow(arena, "AttributesLink"))
     {
         Guid? nullable = person.PersonGUID;
         person.AttributesLink = string.Format("person/{0}/attribute/list", nullable.ToString());
     }
     if (this.ShouldShow(arena, "NotesLink"))
     {
         Guid? personGUID1 = person.PersonGUID;
         person.NotesLink = string.Format("person/{0}/note/list", personGUID1.ToString());
     }
     if (this.ShouldShow(arena, "BirthDate"))
     {
         person.BirthDate = new DateTime?(arena.BirthDate);
     }
     Arena.Core.Family family = null;
     if (this.ShouldShow(arena, "FamilyMemberRoleID"))
     {
         if (family == null)
         {
             family = arena.Family();
         }
         if (family.FamilyID != -1)
         {
             person.FamilyMemberRoleID = new int?(family.FamilyMembers.FindByID(arena.PersonID).FamilyRole.LookupID);
         }
     }
     if (this.ShouldShow(arena, "FamilyMemberRoleValue"))
     {
         if (family == null)
         {
             family = arena.Family();
         }
         if (family.FamilyID != -1)
         {
             person.FamilyMemberRoleValue = family.FamilyMembers.FindByID(arena.PersonID).FamilyRole.Value;
         }
     }
     if (this.ShouldShow(arena, "DateCreated"))
     {
         person.DateCreated = new DateTime?(arena.DateCreated);
     }
     if (this.ShouldShow(arena, "DateModified"))
     {
         person.DateModified = new DateTime?(arena.DateModified);
     }
     if (this.ShouldShow(arena, "AreaID") && arena.Area != null)
     {
         person.AreaID = new int?(arena.Area.AreaID);
     }
     if (this.ShouldShow(arena, "AreaName") && arena.Area != null)
     {
         person.AreaName = arena.Area.Name;
     }
     if (this.ShouldShow(arena, "Emails"))
     {
         foreach (Arena.Core.PersonEmail active in arena.Emails.Active)
         {
             person.AddEmail(new Email()
             {
                 Address = active.Email
             });
         }
     }
     if (this.ShouldShow(arena, "DisplayNotesCount"))
     {
         person.DisplayNotesCount = new int?(arena.GetDisplayNotes(Arena.Core.ArenaContext.Current.Organization.OrganizationID, Arena.Core.ArenaContext.Current.User.Identity.Name).Count);
     }
     if (this.ShouldShow(arena, "FamilyMembersCount"))
     {
         if (family == null)
         {
             family = arena.Family();
         }
         person.FamilyMembersCount = new int?(family.FamilyMembers.Count);
     }
     return person;
 }
Ejemplo n.º 2
0
 public Arena.Services.Contracts.Person FromArena(Arena.Core.Person arena)
 {
     Arena.Services.Contracts.Person person = new Arena.Services.Contracts.Person();
     if (this.ShouldShow(arena, "PersonID"))
     {
         person.PersonID = new int?(arena.PersonID);
     }
     if (this.ShouldShow(arena, "PersonGUID"))
     {
         person.PersonGUID = new Guid?(arena.PersonGUID);
     }
     if (this.ShouldShow(arena, "PersonLink"))
     {
         Guid personGUID = arena.PersonGUID;
         person.PersonLink = string.Format("person/{0}", personGUID.ToString());
     }
     if (this.ShouldShow(arena, "OrganizationID"))
     {
         person.OrganizationID = new int?(arena.OrganizationID);
     }
     if (arena.Campus != null && this.ShouldShow(arena, "CampusID"))
     {
         person.CampusID = new int?(arena.Campus.CampusId);
     }
     if (arena.Campus != null && this.ShouldShow(arena, "CampusName"))
     {
         person.CampusName = arena.Campus.Name;
     }
     if (this.ShouldShow(arena, "TitleID"))
     {
         person.TitleID = new int?(arena.Title.LookupID);
     }
     if (this.ShouldShow(arena, "TitleValue"))
     {
         person.TitleValue = arena.Title.ToString();
     }
     if (this.ShouldShow(arena, "SuffixID"))
     {
         person.SuffixID = new int?(arena.Suffix.LookupID);
     }
     if (this.ShouldShow(arena, "SuffixValue"))
     {
         person.SuffixValue = arena.Suffix.ToString();
     }
     if (this.ShouldShow(arena, "NickName"))
     {
         person.NickName = arena.NickName;
     }
     if (this.ShouldShow(arena, "FirstName"))
     {
         person.FirstName = arena.FirstName;
     }
     if (this.ShouldShow(arena, "MiddleName"))
     {
         person.MiddleName = arena.MiddleName;
     }
     if (this.ShouldShow(arena, "LastName"))
     {
         person.LastName = arena.LastName;
     }
     if (this.ShouldShow(arena, "FullName"))
     {
         person.FullName = arena.FullName;
     }
     if (this.ShouldShow(arena, "FamilyID"))
     {
         person.FamilyID = new int?(arena.FamilyId);
     }
     if (this.ShouldShow(arena, "FamilyName"))
     {
         person.FamilyName = arena.Family().FamilyName;
     }
     if (this.ShouldShow(arena, "FamilyLink"))
     {
         int?familyID = person.FamilyID;
         person.FamilyLink = string.Format("family/{0}", familyID.ToString());
     }
     if (this.ShouldShow(arena, "Age"))
     {
         person.Age = new int?(arena.Age);
     }
     if (this.ShouldShow(arena, "Gender"))
     {
         person.Gender = arena.Gender.ToString();
     }
     if (this.ShouldShow(arena, "Notes"))
     {
         person.Notes = arena.Notes;
     }
     if (this.ShouldShow(arena, "MedicalInformation"))
     {
         person.MedicalInformation = arena.MedicalInformation;
     }
     if (this.ShouldShow(arena, "EnvelopeNumber"))
     {
         person.EnvelopeNumber = new int?(arena.EnvelopeNumber);
     }
     if (this.ShouldShow(arena, "IncludeOnEnvelope"))
     {
         person.IncludeOnEnvelope = new bool?(arena.IncludeOnEnvelope);
     }
     if (this.ShouldShow(arena, "MaritalStatusID"))
     {
         person.MaritalStatusID = new int?(arena.MaritalStatus.LookupID);
     }
     if (this.ShouldShow(arena, "MaritalStatusValue"))
     {
         person.MaritalStatusValue = arena.MaritalStatus.ToString();
     }
     if (this.ShouldShow(arena, "AnniversaryDate"))
     {
         person.AnniversaryDate = new DateTime?(arena.AnniversaryDate);
     }
     if (this.ShouldShow(arena, "MemberStatusID"))
     {
         person.MemberStatusID = new int?(arena.MemberStatus.LookupID);
     }
     if (this.ShouldShow(arena, "MemberStatusValue"))
     {
         person.MemberStatusValue = arena.MemberStatus.ToString();
     }
     if (this.ShouldShow(arena, "RecordStatusID"))
     {
         person.RecordStatusID = new int?(Convert.ToInt32(arena.RecordStatus));
     }
     if (this.ShouldShow(arena, "RecordStatusValue"))
     {
         person.RecordStatusValue = arena.RecordStatus.ToString();
     }
     if (this.ShouldShow(arena, "InactiveReasonID"))
     {
         person.InactiveReasonID = new int?(arena.InactiveReason.LookupID);
     }
     if (this.ShouldShow(arena, "InactiveReasonValue"))
     {
         person.InactiveReasonValue = arena.InactiveReason.ToString();
     }
     if (this.ShouldShow(arena, "ActiveMeter"))
     {
         person.ActiveMeter = new int?(arena.ActiveMeter);
     }
     if (this.ShouldShow(arena, "ContributeIndividually"))
     {
         person.ContributeIndividually = new bool?(arena.ContributeIndividually);
     }
     if (this.ShouldShow(arena, "PrintStatement"))
     {
         person.PrintStatement = new bool?(arena.PrintStatement);
     }
     if (this.ShouldShow(arena, "EmailStatement"))
     {
         person.EmailStatement = new bool?(arena.EmailStatement);
     }
     if (this.ShouldShow(arena, "RegionName"))
     {
         person.RegionName = arena.RegionName;
     }
     if (this.ShouldShow(arena, "BlobID"))
     {
         person.BlobID = new int?(arena.BlobID);
     }
     if (this.ShouldShow(arena, "BlobLink"))
     {
         if (arena.BlobID > 0)
         {
             Guid gUID = arena.Blob.GUID;
             person.BlobLink = base.BuildBlobUrl(gUID.ToString(), -1, Gender.Unknown);
         }
     }
     if (this.ShouldShow(arena, "GivingUnitID"))
     {
         person.GivingUnitID = arena.GivingUnitID;
     }
     if (this.ShouldShow(arena, "ForeignKey"))
     {
         person.ForeignKey = new int?(arena.ForeignKey);
     }
     if (this.ShouldShow(arena, "ForeignKey2"))
     {
         person.ForeignKey2 = new int?(arena.ForeignKey2);
     }
     if (this.ShouldShow(arena, "Addresses"))
     {
         foreach (Arena.Core.PersonAddress arenaAddress in arena.Addresses)
         {
             Address address = new Address()
             {
                 AddressID   = arenaAddress.AddressID,
                 StreetLine1 = arenaAddress.Address.StreetLine1,
                 StreetLine2 = arenaAddress.Address.StreetLine2,
                 City        = arenaAddress.Address.City,
                 State       = arenaAddress.Address.State,
                 PostalCode  = arenaAddress.Address.PostalCode,
                 Country     = arenaAddress.Address.Country
             };
             if (arenaAddress.AddressType != null && arenaAddress.AddressType.LookupID != -1)
             {
                 address.AddressTypeValue = arenaAddress.AddressType.Value;
                 address.AddressTypeID    = arenaAddress.AddressType.LookupID;
             }
             if (arenaAddress.Address.Latitude != 0)
             {
                 address.Latitude = new double?(arenaAddress.Address.Latitude);
             }
             if (arenaAddress.Address.Longitude != 0)
             {
                 address.Longitude = new double?(arenaAddress.Address.Longitude);
             }
             address.Primary = arenaAddress.Primary;
             person.AddAddress(address);
         }
     }
     if (this.ShouldShow(arena, "Phones"))
     {
         foreach (Arena.Core.PersonPhone arenaPhone in arena.Phones)
         {
             Arena.Services.Contracts.Phone phone = new Arena.Services.Contracts.Phone()
             {
                 PhoneTypeID    = arenaPhone.PhoneType.LookupID,
                 PhoneTypeValue = arenaPhone.PhoneType.Value,
                 Unlisted       = arenaPhone.Unlisted,
                 SMSEnabled     = arenaPhone.SMSEnabled,
                 Extension      = arenaPhone.Extension,
                 Number         = arenaPhone.Number
             };
             person.AddPhone(phone);
         }
     }
     if (this.ShouldShow(arena, "AttributesLink"))
     {
         Guid?nullable = person.PersonGUID;
         person.AttributesLink = string.Format("person/{0}/attribute/list", nullable.ToString());
     }
     if (this.ShouldShow(arena, "NotesLink"))
     {
         Guid?personGUID1 = person.PersonGUID;
         person.NotesLink = string.Format("person/{0}/note/list", personGUID1.ToString());
     }
     if (this.ShouldShow(arena, "BirthDate"))
     {
         person.BirthDate = new DateTime?(arena.BirthDate);
     }
     Arena.Core.Family family = null;
     if (this.ShouldShow(arena, "FamilyMemberRoleID"))
     {
         if (family == null)
         {
             family = arena.Family();
         }
         if (family.FamilyID != -1)
         {
             person.FamilyMemberRoleID = new int?(family.FamilyMembers.FindByID(arena.PersonID).FamilyRole.LookupID);
         }
     }
     if (this.ShouldShow(arena, "FamilyMemberRoleValue"))
     {
         if (family == null)
         {
             family = arena.Family();
         }
         if (family.FamilyID != -1)
         {
             person.FamilyMemberRoleValue = family.FamilyMembers.FindByID(arena.PersonID).FamilyRole.Value;
         }
     }
     if (this.ShouldShow(arena, "DateCreated"))
     {
         person.DateCreated = new DateTime?(arena.DateCreated);
     }
     if (this.ShouldShow(arena, "DateModified"))
     {
         person.DateModified = new DateTime?(arena.DateModified);
     }
     if (this.ShouldShow(arena, "AreaID") && arena.Area != null)
     {
         person.AreaID = new int?(arena.Area.AreaID);
     }
     if (this.ShouldShow(arena, "AreaName") && arena.Area != null)
     {
         person.AreaName = arena.Area.Name;
     }
     if (this.ShouldShow(arena, "Emails"))
     {
         foreach (Arena.Core.PersonEmail active in arena.Emails.Active)
         {
             person.AddEmail(new Email()
             {
                 Address = active.Email
             });
         }
     }
     if (this.ShouldShow(arena, "DisplayNotesCount"))
     {
         person.DisplayNotesCount = new int?(arena.GetDisplayNotes(Arena.Core.ArenaContext.Current.Organization.OrganizationID, Arena.Core.ArenaContext.Current.User.Identity.Name).Count);
     }
     if (this.ShouldShow(arena, "FamilyMembersCount"))
     {
         if (family == null)
         {
             family = arena.Family();
         }
         person.FamilyMembersCount = new int?(family.FamilyMembers.Count);
     }
     return(person);
 }