public ModifyResult Update(int personId, PersonAttribute attribute) { Arena.Core.Person person = new Arena.Core.Person(personId); var modifyResult = new ModifyResult(); try { Core.Attribute coreAttribute = null; if (attribute.AttributeID > 0) { coreAttribute = person.Attributes.FindByID(attribute.AttributeID); if (coreAttribute == null) { coreAttribute = new Core.PersonAttribute(attribute.AttributeID); person.Attributes.Add(coreAttribute); } } else { modifyResult.Successful = "False"; modifyResult.ErrorMessage = "Attribute ID is required."; return(modifyResult); } if (!coreAttribute.Allowed(Security.OperationType.Edit, Arena.Core.ArenaContext.Current.User, person)) { modifyResult.Successful = "False"; modifyResult.ErrorMessage = "Permission denied to edit attribute."; return(modifyResult); } coreAttribute.AttributeName = attribute.AttributeName; if (coreAttribute.AttributeType == Enums.DataType.String) { coreAttribute.StringValue = attribute.StringValue; } if (coreAttribute.AttributeType == Enums.DataType.DateTime) { coreAttribute.DateValue = attribute.DateValue.GetValueOrDefault(); } if (coreAttribute.AttributeType == Enums.DataType.Decimal) { coreAttribute.DecimalValue = attribute.DecimalValue.GetValueOrDefault(); } if (coreAttribute.AttributeType == Enums.DataType.Int) { coreAttribute.IntValue = attribute.IntValue.GetValueOrDefault(); } person.SaveAttributes(Arena.Core.ArenaContext.Current.Organization.OrganizationID, Arena.Core.ArenaContext.Current.User.Identity.Name); modifyResult.Successful = "True"; } catch (Exception e) { modifyResult.Successful = "False"; modifyResult.ErrorMessage = e.Message; } return(modifyResult); }
public ModifyResult Update(int personId, PersonAttribute attribute) { Arena.Core.Person person = new Arena.Core.Person(personId); var modifyResult = new ModifyResult(); try { Core.Attribute coreAttribute = null; if (attribute.AttributeID > 0) { coreAttribute = person.Attributes.FindByID(attribute.AttributeID); if (coreAttribute == null) { coreAttribute = new Core.PersonAttribute(attribute.AttributeID); person.Attributes.Add(coreAttribute); } } else { modifyResult.Successful = "False"; modifyResult.ErrorMessage = "Attribute ID is required."; return modifyResult; } if (!coreAttribute.Allowed(Security.OperationType.Edit, Arena.Core.ArenaContext.Current.User, person)) { modifyResult.Successful = "False"; modifyResult.ErrorMessage = "Permission denied to edit attribute."; return modifyResult; } coreAttribute.AttributeName = attribute.AttributeName; if (coreAttribute.AttributeType == Enums.DataType.String) { coreAttribute.StringValue = attribute.StringValue; } if (coreAttribute.AttributeType == Enums.DataType.DateTime) { coreAttribute.DateValue = attribute.DateValue.GetValueOrDefault(); } if (coreAttribute.AttributeType == Enums.DataType.Decimal) { coreAttribute.DecimalValue = attribute.DecimalValue.GetValueOrDefault(); } if (coreAttribute.AttributeType == Enums.DataType.Int) { coreAttribute.IntValue = attribute.IntValue.GetValueOrDefault(); } person.SaveAttributes(Arena.Core.ArenaContext.Current.Organization.OrganizationID, Arena.Core.ArenaContext.Current.User.Identity.Name); modifyResult.Successful = "True"; } catch (Exception e) { modifyResult.Successful = "False"; modifyResult.ErrorMessage = e.Message; } return modifyResult; }
public CccevPerson(int personID) { person = new Arena.Core.Person(personID); }
public CccevPerson() { person = new Arena.Core.Person(); }
private bool ShouldShow(Arena.Core.Person arena, string name) { // First we check to see if this is yourself if (Arena.Core.ArenaContext.Current.Person.PersonID == arena.PersonID) { return(true); } // Next we check to see if this is a family member if (Arena.Core.ArenaContext.Current.Person.FamilyId == arena.FamilyId) { return(true); } // Group Leader Check - If the person they are fetching is one of their // small group members, go ahead and provide visibility Arena.Custom.SECC.Data.SmallGroup.GroupCollection gc = new Arena.Custom.SECC.Data.SmallGroup.GroupCollection(); gc.LoadByLeaderPersonID(Arena.Core.ArenaContext.Current.Person.PersonID); foreach (Arena.SmallGroup.Group g in gc) { foreach (Arena.Core.Person groupMember in g.Members) { if (groupMember.PersonID == arena.PersonID) { return(true); } } Arena.SmallGroup.GroupCluster cluster = g.GroupCluster; while (cluster != null) { // If this is the current group's cluster leader or admin if (cluster.LeaderID == arena.PersonID || cluster.AdminID == arena.PersonID) { return(true); } if (cluster.ParentClusterID > 0) { cluster = new Arena.SmallGroup.GroupCluster(cluster.ParentClusterID); } else { cluster = null; } } } if (!PersonMapper._fieldSecurityMap.ContainsKey(name.ToUpperInvariant())) { return(false); } PermissionCollection permissionCollection = new PermissionCollection(ObjectType.PersonField, PersonMapper._fieldSecurityMap[name.ToUpperInvariant()]); if (!permissionCollection.Allowed(OperationType.View, Arena.Core.ArenaContext.Current.User)) { return(false); } if (this._includeFields == null) { return(true); } return(this._includeFields.Contains(name.ToUpperInvariant())); }
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); }