/// <summary>
/// Executes the specified workflow.
/// </summary>
/// <param name="rockContext">The rock context.</param>
/// <param name="action">The workflow action.</param>
/// <param name="entity">The entity.</param>
/// <param name="errorMessages">The error messages.</param>
/// <returns></returns>
/// <exception cref="System.NotImplementedException"></exception>
public override bool Execute( RockContext rockContext, Model.WorkflowAction action, Object entity, out List<string> errorMessages )
{
var checkInState = GetCheckInState( entity, out errorMessages );
if ( checkInState != null )
{
var family = checkInState.CheckIn.Families.Where( f => f.Selected ).FirstOrDefault();
if ( family != null )
{
var service = new GroupMemberService( rockContext );
foreach ( var groupMember in service.GetByGroupId( family.Group.Id ).AsNoTracking().ToList() )
{
if ( !family.People.Any( p => p.Person.Id == groupMember.PersonId ) )
{
var person = new CheckInPerson();
person.Person = groupMember.Person.Clone( false );
person.FamilyMember = true;
family.People.Add( person );
}
}
return true;
}
else
{
errorMessages.Add( "There is not a family that is selected" );
}
return false;
}
return false;
}