/// <summary> /// To the model. /// </summary> /// <param name="value">The value.</param> /// <returns></returns> public static PersonMerged ToModel(this PersonMergedDto value) { PersonMerged result = new PersonMerged(); value.CopyToModel(result); return(result); }
/// <summary> /// Gets a <see cref="Rock.Model.PersonMerged"/> entity by a <see cref="Rock.Model.Person">Person's</see> previous public key value. /// </summary> /// <param name="publicKey">A <see cref="System.String"/> containing a <see cref="Rock.Model.Person">Person's</see> previous public key value.</param> /// <returns>A <see cref="Rock.Model.PersonMerged"/> entity that contains a <see cref="Rock.Model.Person">Person's</see> new identifiers.</returns> public virtual PersonMerged GetNewByPreviousPublicKey(string publicKey) { try { string[] idParts = publicKey.Split('>'); if (idParts.Length == 2) { int id = Int32.Parse(idParts[0]); Guid guid = new Guid(idParts[1]); PersonMerged personMerged = GetNew(id); if (personMerged != null && personMerged.PreviousPersonGuid.CompareTo(guid) == 0) { return(personMerged); } } return(null); } catch { return(null); } }
/// <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 PersonMergedService personMergedService = new PersonMergedService(); PersonMerged personMerged = personMergedService.Queryable(). Where(p => p.Guid == personGuid && p.Id == personId).FirstOrDefault(); if (personMerged != null) { return(Get(personMerged.Id, true)); } } return(null); }
/// <summary> /// Copies the properties from another PersonMerged object to this PersonMerged object /// </summary> /// <param name="target">The target.</param> /// <param name="source">The source.</param> public static void CopyPropertiesFrom(this PersonMerged target, PersonMerged source) { target.PreviousPersonId = source.PreviousPersonId; target.PreviousPersonGuid = source.PreviousPersonGuid; target.NewPersonId = source.NewPersonId; target.NewPersonGuid = source.NewPersonGuid; target.Id = source.Id; target.Guid = source.Guid; }
/// <summary> /// Gets a <see cref="Rock.Model.Person">Person's</see> current public key by their previous public key value. /// </summary> /// <param name="publicKey">A <see cref="System.String"/> containing the <see cref="Rock.Model.Person">Person's</see> previous public key.</param> /// <returns>A <see cref="System.String"/> representing the <see cref="Rock.Model.Person">Person's</see> current public key value.</returns> public string Current(string publicKey) { PersonMerged personMerged = GetNewByPreviousEncryptedKey(publicKey); while (personMerged != null) { publicKey = personMerged.NewEncryptedKey; personMerged = GetNewByPreviousEncryptedKey(publicKey); } return(publicKey); }
/// <summary> /// Gets a <see cref="Rock.Model.Person">Person's</see> current Guid by their previous Guid. /// </summary> /// <param name="personGuid">A <see cref="System.Int32"/> representing a <see cref="Rock.Model.Person">Person's</see> previous Guid.</param> /// <returns>A <see cref="System.Guid"/> representing a <see cref="Rock.Model.Person">Person's</see> new Guid.</returns> public Guid Current(Guid personGuid) { PersonMerged personMerged = GetNew(personGuid); while (personMerged != null) { personGuid = personMerged.NewPersonGuid; personMerged = GetNew(personGuid); } return(personGuid); }
/// <summary> /// Gets a <see cref="Rock.Model.Person">Person's</see> current PersonId by their previous PersonId. /// </summary> /// <param name="personId">A <see cref="System.Int32" /> representing a <see cref="Rock.Model.Person">Person's</see> previous PersonId.</param> /// <returns>A <see cref="System.Int32"/> representing a <see cref="Rock.Model.Person">Person's</see> current PersonId.</returns> public int Current(int personId) { PersonMerged personMerged = GetNew(personId); while (personMerged != null) { personId = personMerged.NewPersonId; personMerged = GetNew(personId); } return(personId); }
/// <summary> /// Clones this PersonMerged object to a new PersonMerged object /// </summary> /// <param name="source">The source.</param> /// <param name="deepCopy">if set to <c>true</c> a deep copy is made. If false, only the basic entity properties are copied.</param> /// <returns></returns> public static PersonMerged Clone(this PersonMerged source, bool deepCopy) { if (deepCopy) { return(source.Clone() as PersonMerged); } else { var target = new PersonMerged(); target.CopyPropertiesFrom(source); return(target); } }
/// <summary> /// Instantiates a new DTO object from the entity /// </summary> /// <param name="personMerged"></param> public PersonMergedDto(PersonMerged personMerged) { CopyFromModel(personMerged); }
/// <summary> /// To the dto. /// </summary> /// <param name="value">The value.</param> /// <returns></returns> public static PersonMergedDto ToDto(this PersonMerged value) { return(new PersonMergedDto(value)); }