コード例 #1
0
 /// <inheritdoc/>
 public void PostSave(IEntitySaveEntry entry)
 {
     Entry = entry;
     PostSave();
 }
コード例 #2
0
 /// <inheritdoc/>
 public void SaveFailed(IEntitySaveEntry entry)
 {
     Entry = entry;
     SaveFailed();
 }
コード例 #3
0
            private ProcessConnectionRequestChange.Message GetProcessConnectionRequestChangeMessage(IEntitySaveEntry entry, ConnectionRequest connectionRequest, int?currentPersonAliasId)
            {
                var message = new ProcessConnectionRequestChange.Message();

                if (connectionRequest != null)
                {
                    message.State = entry.State;

                    // If the current person alias has a value, set that value for the message.
                    if (currentPersonAliasId.HasValue)
                    {
                        message.InitiatorPersonAliasId = currentPersonAliasId;
                    }

                    // If this isn't a deleted connection request, get the connection request guid
                    if (message.State != EntityContextState.Deleted)
                    {
                        message.ConnectionRequestGuid = connectionRequest.Guid;

                        if (connectionRequest.PersonAlias != null)
                        {
                            message.PersonId = connectionRequest.PersonAlias.PersonId;
                        }
                        else if (connectionRequest.PersonAliasId != default)
                        {
                            message.PersonId = new PersonAliasService(new RockContext()).GetPersonId(connectionRequest.PersonAliasId);
                        }

                        if (connectionRequest.ConnectionOpportunity != null)
                        {
                            message.ConnectionTypeId = connectionRequest.ConnectionOpportunity.ConnectionTypeId;
                        }

                        message.ConnectionOpportunityId = connectionRequest.ConnectionOpportunityId;
                        message.ConnectorPersonAliasId  = connectionRequest.ConnectorPersonAliasId;
                        message.ConnectionState         = connectionRequest.ConnectionState;
                        message.ConnectionStatusId      = connectionRequest.ConnectionStatusId;
                        message.AssignedGroupId         = connectionRequest.AssignedGroupId;

                        if (message.State == EntityContextState.Modified)
                        {
                            message.PreviousConnectionOpportunityId = entry.OriginalValues[nameof(ConnectionRequest.ConnectionOpportunityId)].ToStringSafe().AsIntegerOrNull();
                            message.PreviousConnectorPersonAliasId  = entry.OriginalValues[nameof(ConnectionRequest.ConnectorPersonAliasId)].ToStringSafe().AsIntegerOrNull();
                            message.PreviousConnectionState         = entry.OriginalValues[nameof(ConnectionRequest.ConnectionState)].ToStringSafe().ConvertToEnum <ConnectionState>();
                            message.PreviousConnectionStatusId      = entry.OriginalValues[nameof(ConnectionRequest.ConnectionStatusId)].ToStringSafe().AsInteger();
                            message.PreviousAssignedGroupId         = entry.OriginalValues[nameof(ConnectionRequest.AssignedGroupId)].ToStringSafe().AsIntegerOrNull();
                        }
                    }
                }

                return(message);
            }
コード例 #4
0
 /// <inheritdoc/>
 public void PreSave(IEntitySaveEntry entry)
 {
     Entry = entry;
     PreSave();
 }
コード例 #5
0
            /// <summary>
            /// Gets the update achievement attempt message.
            /// </summary>
            /// <param name="entry">The entry.</param>
            /// <returns>UpdateAchievementAttempt.Message.</returns>
            private UpdateAchievementAttempt.Message GetUpdateAchievementAttemptMessage(IEntitySaveEntry entry)
            {
                var updateAchievementAttemptMsg = new UpdateAchievementAttempt.Message();

                if (entry.State != EntityContextState.Added && entry.State != EntityContextState.Modified)
                {
                    return(updateAchievementAttemptMsg);
                }

                var achievementAttempt = entry.Entity as AchievementAttempt;

                bool wasClosed     = false;
                bool wasSuccessful = false;

                if (entry.State != EntityContextState.Added)
                {
                    wasClosed     = ( bool )entry.OriginalValues[nameof(AchievementAttempt.IsClosed)];
                    wasSuccessful = ( bool )entry.OriginalValues[nameof(AchievementAttempt.IsSuccessful)];
                }

                // Add a transaction to process workflows and add steps
                updateAchievementAttemptMsg = new UpdateAchievementAttempt.Message
                {
                    AchievementAttemptGuid = achievementAttempt.Guid,
                    IsNowStarting          = entry.State == EntityContextState.Added,
                    IsNowEnding            = !wasClosed && achievementAttempt.IsClosed,
                    IsNowSuccessful        = !wasSuccessful && achievementAttempt.IsSuccessful,
                    AchievementTypeId      = achievementAttempt.AchievementTypeId,
                    StartDate = achievementAttempt.AchievementAttemptStartDateTime,
                    EndDate   = achievementAttempt.AchievementAttemptEndDateTime
                };

                return(updateAchievementAttemptMsg);
            }