Exemplo n.º 1
0
 /// <summary>
 /// Copies the properties from another Streak object to this Streak object
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="source">The source.</param>
 public static void CopyPropertiesFrom(this Streak target, Streak source)
 {
     target.Id = source.Id;
     target.CurrentStreakCount      = source.CurrentStreakCount;
     target.CurrentStreakStartDate  = source.CurrentStreakStartDate;
     target.EngagementCount         = source.EngagementCount;
     target.EngagementMap           = source.EngagementMap;
     target.EnrollmentDate          = source.EnrollmentDate;
     target.ExclusionMap            = source.ExclusionMap;
     target.ForeignGuid             = source.ForeignGuid;
     target.ForeignKey              = source.ForeignKey;
     target.InactiveDateTime        = source.InactiveDateTime;
     target.LocationId              = source.LocationId;
     target.LongestStreakCount      = source.LongestStreakCount;
     target.LongestStreakEndDate    = source.LongestStreakEndDate;
     target.LongestStreakStartDate  = source.LongestStreakStartDate;
     target.PersonAliasId           = source.PersonAliasId;
     target.StreakTypeId            = source.StreakTypeId;
     target.CreatedDateTime         = source.CreatedDateTime;
     target.ModifiedDateTime        = source.ModifiedDateTime;
     target.CreatedByPersonAliasId  = source.CreatedByPersonAliasId;
     target.ModifiedByPersonAliasId = source.ModifiedByPersonAliasId;
     target.Guid      = source.Guid;
     target.ForeignId = source.ForeignId;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Deletes the specified item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        public override bool Delete(Streak item)
        {
            // Since Entity Framework cannot cascade delete achievement attempts because of a possible circular reference,
            // we need to delete them here
            var attemptService = new StreakAchievementAttemptService(Context as RockContext);
            var attempts       = attemptService.Queryable().Where(a => a.StreakId == item.Id);

            attemptService.DeleteRange(attempts);

            // Now we can delete the streak as normal
            return(base.Delete(item));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Clones this Streak object to a new Streak 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 Streak Clone(this Streak source, bool deepCopy)
 {
     if (deepCopy)
     {
         return(source.Clone() as Streak);
     }
     else
     {
         var target = new Streak();
         target.CopyPropertiesFrom(source);
         return(target);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Copy streak data to an enrollment model
        /// </summary>
        /// <param name="source"></param>
        /// <param name="target"></param>
        private static void CopyStreakDataToStreakModel(StreakData source, Streak target)
        {
            if (source == null || target == null)
            {
                return;
            }

            target.EngagementCount = source.EngagementCount;

            target.LongestStreakCount     = source.LongestStreakCount;
            target.LongestStreakStartDate = source.LongestStreakStartDate;
            target.LongestStreakEndDate   = source.LongestStreakEndDate;

            target.CurrentStreakCount     = source.CurrentStreakCount;
            target.CurrentStreakStartDate = source.CurrentStreakStartDate;
        }