public async Task <IActionResult> OnPostReSyncAsync(int?dealId) { if (dealId == null) { return(NotFound()); } APIKey key = await _apiKeyService.GetAPIKeyAsync(); await _hubSpotToConstantContactService .TransferContactsFromHubSpotToConstantContact((int)dealId, key); return(RedirectToPage("Index")); }
public async Task <IActionResult> OnGetAsync() { //Get current filters (want to exclude from dropdown) List <DealStageFilter> filters = await _context.DealStageFilters .Include(d => d.User) .Where(d => d.User.UserName == HttpContext.User.Identity.Name) .ToListAsync(); List <string> ids = filters.Select(f => f.StageID).ToList(); //Fetch all deal stage options from hubspot APIKey key = await _apiKeyService.GetAPIKeyAsync(); List <dynamic> dealStages = await _hubSpotService.GetDealStagesAsync(key); List <dynamic> options = new List <dynamic>(); foreach (dynamic stage in dealStages) { if (!ids.Contains(stage.stageId.ToString())) { dynamic value = new ExpandoObject(); value.label = stage.label; value.stageId = stage.stageId; value.pipelineLabel = stage.pipelineLabel; dynamic option = new ExpandoObject(); option.DisplayText = stage.pipelineLabel + " - " + stage.label; option.Value = JsonConvert.SerializeObject(value); options.Add(option); } } ViewData["UserId"] = new SelectList(options, "Value", "DisplayText"); return(Page()); }
private async Task <string> FetchContactListsJsonAsync() { APIKey apiKey = await _apiKeyService.GetAPIKeyAsync(); string result = string.Empty; using (HttpClient client = new HttpClient()) { string url = "https://api.constantcontact.com/v2/lists?api_key=" + apiKey.ConstantContactPublicKey; using (HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Get, url)) { req.Headers.Add("Authorization", "Bearer " + apiKey.ConstantContactPrivateKey); using (HttpResponseMessage response = await client.SendAsync(req)) { result = await response.Content.ReadAsStringAsync(); } } } return(result); }
public async Task <IActionResult> OnGetAsync() { APIKey = await _apiKeyService.GetAPIKeyAsync(); return(Page()); }