/// <summary> /// Sends the update group member message. /// Don't do this in pre-save as it can cause a Race Condition with the message bus and the DB save. /// </summary> private void SendUpdateGroupMemberMessage() { var updateGroupMemberMsg = new UpdateGroupMember.Message { State = State, GroupId = Entity.GroupId, PersonId = Entity.PersonId, GroupMemberStatus = Entity.GroupMemberStatus, GroupMemberRoleId = Entity.GroupRoleId, IsArchived = Entity.IsArchived }; if (Entity.Group != null) { updateGroupMemberMsg.GroupTypeId = Entity.Group.GroupTypeId; } // If this isn't a new group member, get the previous status and role values if (State == EntityContextState.Modified) { updateGroupMemberMsg.PreviousGroupMemberStatus = OriginalValues[nameof(GroupMember.GroupMemberStatus)].ToStringSafe().ConvertToEnum <GroupMemberStatus>(); updateGroupMemberMsg.PreviousGroupMemberRoleId = OriginalValues[nameof(GroupMember.GroupRoleId)].ToStringSafe().AsInteger(); updateGroupMemberMsg.PreviousIsArchived = OriginalValues[nameof(GroupMember.IsArchived)].ToStringSafe().AsBoolean(); } // If this isn't a deleted group member, get the group member guid if (State != EntityContextState.Deleted) { updateGroupMemberMsg.GroupMemberGuid = Entity.Guid; } updateGroupMemberMsg.Send(); }