/// <summary> /// Gets the by encrypted ID. /// </summary> /// <param name="encryptedID">The encrypted ID.</param> /// <returns></returns> public Person GetByEncryptedID(string encryptedID) { string identifier = Rock.Security.Encryption.DecryptString(encryptedID); string[] idParts = identifier.Split('|'); if (idParts.Length == 2) { Guid personGuid = new Guid(idParts[0]); int personId = Int32.Parse(idParts[1]); Person person = Queryable(). Where(p => p.Guid == personGuid && p.Id == personId).FirstOrDefault(); if (person != null) { return(person); } // Check to see if the record was merged PersonTrailService personTrailService = new PersonTrailService(); PersonTrail personTrail = personTrailService.Queryable(). Where(p => p.Guid == personGuid && p.Id == personId).FirstOrDefault(); if (personTrail != null) { return(Get(personTrail.Id, true)); } } return(null); }
/// <summary> /// Gets the by encrypted ID. /// </summary> /// <param name="encryptedID">The encrypted ID.</param> /// <returns></returns> public Person GetByEncryptedID( string encryptedID ) { string encryptionPhrase = ConfigurationManager.AppSettings["EncryptionPhrase"]; if ( String.IsNullOrWhiteSpace( encryptionPhrase ) ) encryptionPhrase = "Rock Rocks!"; string identifier = Rock.Security.Encryption.DecryptString( encryptedID, encryptionPhrase ); string[] idParts = identifier.Split( '|' ); if ( idParts.Length == 2 ) { Guid personGuid = new Guid( idParts[0] ); int personId = Int32.Parse( idParts[1] ); Person person = Repository.AsQueryable(). Where( p => p.Guid == personGuid && p.Id == personId ).FirstOrDefault(); if ( person != null ) return person; // Check to see if the record was merged PersonTrailService personTrailService = new PersonTrailService(); PersonTrail personTrail = personTrailService.Queryable(). Where( p => p.Guid == personGuid && p.Id == personId ).FirstOrDefault(); if ( personTrail != null ) return Get( personTrail.Id, true ); } return null; }
/// <summary> /// Gets Person by Id /// </summary> /// <param name="id">The id.</param> /// <param name="followTrail">if set to <c>true</c> follow the merge trail.</param> /// <returns> /// Person object. /// </returns> public Rock.CRM.Person Get( int id, bool followTrail ) { if ( followTrail ) id = new PersonTrailService().Current( id ); return Get( id ); }
/// <summary> /// Gets Person by Guid /// </summary> /// <param name="publicKey">The public key.</param> /// <param name="followTrail">if set to <c>true</c> follow the merge trail</param> /// <returns> /// Person object. /// </returns> public Rock.CRM.Person GetByEncryptedKey(string encryptedKey, bool followTrail) { if (followTrail) { encryptedKey = new PersonTrailService().Current(encryptedKey); } return(GetByEncryptedKey(encryptedKey)); }
/// <summary> /// Gets Person by Id /// </summary> /// <param name="id">The id.</param> /// <param name="followTrail">if set to <c>true</c> follow the merge trail.</param> /// <returns> /// Person object. /// </returns> public Rock.CRM.Person Get(int id, bool followTrail) { if (followTrail) { id = new PersonTrailService().Current(id); } return(Get(id)); }
/// <summary> /// Gets Person by Guid /// </summary> /// <param name="guid">Guid.</param> /// <param name="followTrail">if set to <c>true</c> follow the merge trail</param> /// <returns> /// Person object. /// </returns> public Rock.CRM.Person GetByGuid( Guid guid, bool followTrail ) { if ( followTrail ) guid = new PersonTrailService().Current( guid ); return GetByGuid( guid ); }