private static Keyword AttachKeyword(T70Context context) { var keywordRepo = context.Repository <Keyword>(new { AccountId = ACCOUNT_ID, ChannelId = CHANNEL_ID }); var keyword = keywordRepo.Get(KEYWORD_ID); if (keyword.CampaignId.HasValue) { if (keyword.CampaignId == CAMPAIGN_ID) { Console.WriteLine("Keyword {0} already attached to campaign {1}", keyword.Id, CAMPAIGN_ID); return(keyword); } Console.WriteLine( "NOTICE: Keyword {0} is already attached to campaign {1}, this will get changed.", keyword.Id, keyword.CampaignId); } context.AttachKeywordTo(keyword, CAMPAIGN_ID); return(keyword); }
private const int KEYWORD_ID = 0; // TODO: Fill in with your keyword ID #endregion Fields #region Methods private static Keyword AttachKeyword(T70Context context) { var keywordRepo = context.Repository<Keyword>(new { AccountId = ACCOUNT_ID, ChannelId = CHANNEL_ID }); var keyword = keywordRepo.Get(KEYWORD_ID); if (keyword.CampaignId.HasValue) { if (keyword.CampaignId == CAMPAIGN_ID) { Console.WriteLine("Keyword {0} already attached to campaign {1}", keyword.Id, CAMPAIGN_ID); return keyword; } Console.WriteLine( "NOTICE: Keyword {0} is already attached to campaign {1}, this will get changed.", keyword.Id, keyword.CampaignId); } context.AttachKeywordTo(keyword, CAMPAIGN_ID); return keyword; }
private static void DetachKeyword(T70Context context, Keyword keyword) { context.AttachKeywordTo(keyword, null); }