Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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);
            }
        }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
 /// <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;
 }
Ejemplo n.º 5
0
        /// <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);
        }
Ejemplo n.º 6
0
        /// <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);
        }
Ejemplo n.º 7
0
        /// <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);
        }
Ejemplo n.º 8
0
 /// <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);
     }
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Instantiates a new DTO object from the entity
 /// </summary>
 /// <param name="personMerged"></param>
 public PersonMergedDto(PersonMerged personMerged)
 {
     CopyFromModel(personMerged);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// To the dto.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <returns></returns>
 public static PersonMergedDto ToDto(this PersonMerged value)
 {
     return(new PersonMergedDto(value));
 }