From b764aebcd1f3241443d13a7b50c1eb4d0254625b Mon Sep 17 00:00:00 2001 From: Christian Arenas Date: Thu, 15 Jun 2017 19:23:10 +0200 Subject: [PATCH] Add campaign service methods --- src/Web/WebMVC/Services/CampaignService.cs | 19 ++++++++++++++++--- src/Web/WebMVC/Services/ICampaignService.cs | 4 +++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/Web/WebMVC/Services/CampaignService.cs b/src/Web/WebMVC/Services/CampaignService.cs index 413f18512..fa5bd7095 100644 --- a/src/Web/WebMVC/Services/CampaignService.cs +++ b/src/Web/WebMVC/Services/CampaignService.cs @@ -31,15 +31,28 @@ _httpContextAccesor = httpContextAccesor ?? throw new ArgumentNullException(nameof(httpContextAccesor)); } - public async Task> GetCampaigns() + public async Task> GetCampaigns() { var userId = GetUserIdentity(); - var allCampaignItemsUri = API.Marketing.GetAllCampaigns(_remoteServiceBaseUrl, userId); + var allCampaignItemsUri = API.Marketing.GetAllCampaigns(_remoteServiceBaseUrl, Guid.Parse(userId)); var authorizationToken = await GetUserTokenAsync(); var dataString = await _apiClient.GetStringAsync(allCampaignItemsUri, authorizationToken); - var response = JsonConvert.DeserializeObject>(dataString); + var response = JsonConvert.DeserializeObject>(dataString); + + return response; + } + + public async Task GetCampaignById(int id) + { + var userId = GetUserIdentity(); + var campaignByIdItemUri = API.Marketing.GetAllCampaignById(_remoteServiceBaseUrl, id); + + var authorizationToken = await GetUserTokenAsync(); + var dataString = await _apiClient.GetStringAsync(campaignByIdItemUri, authorizationToken); + + var response = JsonConvert.DeserializeObject(dataString); return response; } diff --git a/src/Web/WebMVC/Services/ICampaignService.cs b/src/Web/WebMVC/Services/ICampaignService.cs index 7b474e943..2546d7a01 100644 --- a/src/Web/WebMVC/Services/ICampaignService.cs +++ b/src/Web/WebMVC/Services/ICampaignService.cs @@ -6,6 +6,8 @@ public interface ICampaignService { - Task> GetCampaigns(); + Task> GetCampaigns(); + + Task GetCampaignById(int id); } } \ No newline at end of file