Modify the campaign response of the marketing api
This commit is contained in:
parent
80c10a1465
commit
9bdfddc496
@ -0,0 +1,19 @@
|
||||
namespace eShopOnContainers.Core.Models.Marketing
|
||||
{
|
||||
using System;
|
||||
|
||||
public class CampaignItem
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
public DateTime From { get; set; }
|
||||
|
||||
public DateTime To { get; set; }
|
||||
|
||||
public string PictureUri { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
namespace eShopOnContainers.Core.Models.Marketing
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class CampaignRoot
|
||||
{
|
||||
public int PageIndex { get; set; }
|
||||
public int PageSize { get; set; }
|
||||
public int Count { get; set; }
|
||||
public List<CampaignItem> Data { get; set; }
|
||||
}
|
||||
}
|
@ -11,9 +11,9 @@ namespace eShopOnContainers.Core.Services.Marketing
|
||||
|
||||
public class CampaignMockService : ICampaignService
|
||||
{
|
||||
private readonly ObservableCollection<Campaign> _mockCampaign = new ObservableCollection<Campaign>
|
||||
private readonly ObservableCollection<CampaignItem> _mockCampaign = new ObservableCollection<CampaignItem>
|
||||
{
|
||||
new Campaign
|
||||
new CampaignItem
|
||||
{
|
||||
Id = Common.Common.MockCampaignd01,
|
||||
PictureUri = Device.RuntimePlatform != Device.Windows
|
||||
@ -25,7 +25,7 @@ namespace eShopOnContainers.Core.Services.Marketing
|
||||
To = DateTime.Now.AddDays(7)
|
||||
},
|
||||
|
||||
new Campaign
|
||||
new CampaignItem
|
||||
{
|
||||
Id = Common.Common.MockCampaignd02,
|
||||
PictureUri = Device.RuntimePlatform != Device.Windows
|
||||
@ -38,18 +38,16 @@ namespace eShopOnContainers.Core.Services.Marketing
|
||||
}
|
||||
};
|
||||
|
||||
public async Task<ObservableCollection<Campaign>> GetAllCampaignsAsync(string userId, string token)
|
||||
public async Task<ObservableCollection<CampaignItem>> GetAllCampaignsAsync(string userId, string token)
|
||||
{
|
||||
await Task.Delay(500);
|
||||
|
||||
return _mockCampaign;
|
||||
}
|
||||
|
||||
public async Task<Campaign> GetCampaignByIdAsync(int camapignId, string token)
|
||||
public async Task<CampaignItem> GetCampaignByIdAsync(int campaignId, string token)
|
||||
{
|
||||
await Task.Delay(500);
|
||||
|
||||
return _mockCampaign.First();
|
||||
return _mockCampaign.SingleOrDefault(c => c.Id == campaignId);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,7 @@
|
||||
namespace eShopOnContainers.Core.Services.Marketing
|
||||
using eShopOnContainers.Core.Extensions;
|
||||
using eShopOnContainers.Core.Helpers;
|
||||
|
||||
namespace eShopOnContainers.Core.Services.Marketing
|
||||
{
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
@ -15,20 +18,36 @@
|
||||
_requestProvider = requestProvider;
|
||||
}
|
||||
|
||||
public async Task<ObservableCollection<Campaign>> GetAllCampaignsAsync(string userId, string token)
|
||||
public async Task<ObservableCollection<CampaignItem>> GetAllCampaignsAsync(string userId, string token)
|
||||
{
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.MarketingEndpoint);
|
||||
|
||||
builder.Path = $"api/v1/campaigns/{userId}";
|
||||
builder.Path = $"api/v1/campaigns/user/{userId}";
|
||||
|
||||
string uri = builder.ToString();
|
||||
|
||||
return await _requestProvider.GetAsync<ObservableCollection<Campaign>>(uri, token);
|
||||
CampaignRoot campaign =
|
||||
await _requestProvider.GetAsync<CampaignRoot>(uri, token);
|
||||
|
||||
if (campaign?.Data != null)
|
||||
{
|
||||
ServicesHelper.FixCatalogItemPictureUri(campaign?.Data);
|
||||
|
||||
return campaign?.Data.ToObservableCollection();
|
||||
}
|
||||
|
||||
return new ObservableCollection<CampaignItem>();
|
||||
}
|
||||
|
||||
public Task<Campaign> GetCampaignByIdAsync(int campaignId, string token)
|
||||
public async Task<CampaignItem> GetCampaignByIdAsync(int campaignId, string token)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.Instance.MarketingEndpoint);
|
||||
|
||||
builder.Path = $"api/v1/campaigns/{campaignId}";
|
||||
|
||||
string uri = builder.ToString();
|
||||
|
||||
return await _requestProvider.GetAsync<CampaignItem>(uri, token);
|
||||
}
|
||||
}
|
||||
}
|
@ -7,8 +7,8 @@ namespace eShopOnContainers.Core.Services.Marketing
|
||||
|
||||
public interface ICampaignService
|
||||
{
|
||||
Task<ObservableCollection<Campaign>> GetAllCampaignsAsync(string userId, string token);
|
||||
Task<ObservableCollection<CampaignItem>> GetAllCampaignsAsync(string userId, string token);
|
||||
|
||||
Task<Campaign> GetCampaignByIdAsync(int id, string token);
|
||||
Task<CampaignItem> GetCampaignByIdAsync(int id, string token);
|
||||
}
|
||||
}
|
@ -44,6 +44,9 @@
|
||||
</Compile>
|
||||
<Compile Include="Behaviors\Base\BindableBehavior.cs" />
|
||||
<Compile Include="Behaviors\EventToCommandBehavior.cs" />
|
||||
<Compile Include="Controls\MoreDetailsCampaignButton.xaml.cs">
|
||||
<DependentUpon>MoreDetailsCampaignButton.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\AddBasketButton.xaml.cs">
|
||||
<DependentUpon>AddBasketButton.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -72,7 +75,8 @@
|
||||
<Compile Include="Models\Catalog\CatalogRoot.cs" />
|
||||
<Compile Include="Models\Catalog\CatalogType.cs" />
|
||||
<Compile Include="Models\Location\Location.cs" />
|
||||
<Compile Include="Models\Marketing\Campaign.cs" />
|
||||
<Compile Include="Models\Marketing\CampaignItem.cs" />
|
||||
<Compile Include="Models\Marketing\CampaignRoot.cs" />
|
||||
<Compile Include="Models\Navigation\TabParameter.cs" />
|
||||
<Compile Include="Models\Orders\CardType.CS" />
|
||||
<Compile Include="Models\Orders\Order.cs" />
|
||||
@ -121,6 +125,7 @@
|
||||
<Compile Include="ViewModels\Base\ViewModelBase.cs" />
|
||||
<Compile Include="ViewModels\Base\ViewModelLocator.cs" />
|
||||
<Compile Include="ViewModels\BasketViewModel.cs" />
|
||||
<Compile Include="ViewModels\CampaignDetailsViewModel.cs" />
|
||||
<Compile Include="ViewModels\CampaignViewModel.cs" />
|
||||
<Compile Include="ViewModels\CatalogViewModel.cs" />
|
||||
<Compile Include="ViewModels\CheckoutViewModel.cs" />
|
||||
@ -138,6 +143,9 @@
|
||||
<Compile Include="Views\CatalogView.xaml.cs">
|
||||
<DependentUpon>CatalogView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\CampaignDetailsView.xaml.cs">
|
||||
<DependentUpon>CampaignDetailsView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\CheckoutView.xaml.cs">
|
||||
<DependentUpon>CheckoutView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -171,6 +179,9 @@
|
||||
<Compile Include="Views\Templates\OrderTemplate.xaml.cs">
|
||||
<DependentUpon>OrderTemplate.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\Templates\CampaignTemplate.xaml.cs">
|
||||
<DependentUpon>CampaignTemplate.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\Templates\ProductTemplate.xaml.cs">
|
||||
<DependentUpon>ProductTemplate.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -283,6 +294,24 @@
|
||||
<HintPath>..\..\..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.6\Profile\Profile44\System.ComponentModel.Annotations.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Views\CampaignDetailsView.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Views\Templates\CampaignTemplate.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Controls\MoreDetailsCampaignButton.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
|
Loading…
x
Reference in New Issue
Block a user