private Dictionary<string, object> GetRockCampusByArenaId( int arenaCampusId ) { RockMap.CampusMap campusMap = new RockMap.CampusMap( Service ); return campusMap.GetByForeignId( arenaCampusId.ToString() ); }
public override void ExportRecord( string identifier ) { int arenaCampusId = 0; if ( !int.TryParse( identifier, out arenaCampusId ) ) { OnExportAttemptCompleted( identifier, false ); return; } Campus arenaCampus = GetArenaCampus( arenaCampusId ); if(arenaCampus == null) { OnExportAttemptCompleted(identifier, false); return; } if(arenaCampus.leader_person_id == null) { OnExportAttemptCompleted( identifier, true ); return; } Dictionary<string, object> rockCampus = GetRockCampusByArenaId( arenaCampusId ); if ( rockCampus == null ) { var campusTask = SaveCampus( arenaCampusId ); if ( campusTask.Result != null ) { rockCampus = GetRockCampus( (int)campusTask.Result ); } else { OnExportAttemptCompleted( identifier, false ); return; } } Dictionary<string, object> campusLeader = GetRockCampusLeaderByArenaId( (int) arenaCampus.leader_person_id ); if ( campusLeader == null ) { var personTask = SaveLeader( (int)arenaCampus.leader_person_id ); if ( personTask.Result != null ) { campusLeader = GetRockCampusLeader( (int)personTask.Result ); if ( campusLeader == null ) { OnExportAttemptCompleted( identifier, false ); return; } } } RockMap.CampusMap campusMap = new RockMap.CampusMap( Service ); bool isSystem = (bool)rockCampus["IsSystem"]; string name = (string)rockCampus["Name"]; string shortCode = (string)rockCampus["ShortCode"]; int? locationId = (int?)rockCampus["LocationId"]; Guid guid = (Guid)rockCampus["Guid"]; string foreignId = (string)rockCampus["ForeignId"]; string phoneNumber = (string)rockCampus["PhoneNumber"]; string serviceTimes = (string)rockCampus["ServiceTimes"]; string description = (string)rockCampus["Description"]; bool isActive = (bool)rockCampus["IsActive"]; string url = (string)rockCampus["Url"]; int leaderPersonAliasId = (int)campusLeader["PrimaryAliasId"]; int? campusId = campusMap.SaveCampus( isSystem, name, shortCode, locationId, phoneNumber, leaderPersonAliasId, serviceTimes, foreignId, (int)rockCampus["Id"] ); if ( campusId != null ) { OnExportAttemptCompleted( identifier, true, campusId ); } else { OnExportAttemptCompleted( identifier, false ); } }
private Dictionary<string, object> GetRockCampus( int rockCampusId ) { RockMap.CampusMap campusMap = new RockMap.CampusMap( Service ); return campusMap.GetById( rockCampusId ); }