Skip to content

Commit dfae447

Browse files
committed
Merge branch 'marketingcampaign' into dev
# Conflicts: # eShopOnContainers-ServicesAndWebApps.sln
2 parents 981f4e2 + 6ff6864 commit dfae447

41 files changed

Lines changed: 1664 additions & 5 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cli-windows/add-firewall-rules-for-sts-auth-thru-docker.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ try {
2121
Write-Host "Rule found"
2222
}
2323
catch [Exception] {
24-
New-NetFirewallRule -DisplayName eShopOnContainers-Inbound -Confirm -Description "eShopOnContainers Inbound Rule for port range 5100-5105" -LocalAddress Any -LocalPort 5100-5105 -Protocol tcp -RemoteAddress Any -RemotePort Any -Direction Inbound
25-
New-NetFirewallRule -DisplayName eShopOnContainers-Outbound -Confirm -Description "eShopOnContainers Outbound Rule for port range 5100-5105" -LocalAddress Any -LocalPort 5100-5105 -Protocol tcp -RemoteAddress Any -RemotePort Any -Direction Outbound
24+
New-NetFirewallRule -DisplayName eShopOnContainers-Inbound -Confirm -Description "eShopOnContainers Inbound Rule for port range 5100-5110" -LocalAddress Any -LocalPort 5100-5110 -Protocol tcp -RemoteAddress Any -RemotePort Any -Direction Inbound
25+
New-NetFirewallRule -DisplayName eShopOnContainers-Outbound -Confirm -Description "eShopOnContainers Outbound Rule for port range 5100-5110" -LocalAddress Any -LocalPort 5100-5110 -Protocol tcp -RemoteAddress Any -RemotePort Any -Direction Outbound
2626
}

docker-compose.override.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ services:
4949
ports:
5050
- "5102:80"
5151

52+
marketing.api:
53+
environment:
54+
- ASPNETCORE_ENVIRONMENT=Development
55+
- ASPNETCORE_URLS=http://0.0.0.0:80
56+
- ConnectionString=Server=sql.data;Database=Microsoft.eShopOnContainers.Services.MarketingDb;User Id=sa;Password=Pass@word
57+
- identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105.
58+
ports:
59+
- "5110:80"
60+
5261
webspa:
5362
environment:
5463
- ASPNETCORE_ENVIRONMENT=Development
@@ -94,4 +103,4 @@ services:
94103
- mvc=http://webmvc/hc
95104
- spa=http://webspa/hc
96105
ports:
97-
- "5107:80"
106+
- "5107:80"

docker-compose.prod.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ services:
5454
ports:
5555
- "5102:80"
5656

57+
marketing.api:
58+
environment:
59+
- ASPNETCORE_ENVIRONMENT=Production
60+
- ASPNETCORE_URLS=http://0.0.0.0:80
61+
- ConnectionString=Server=sql.data;Database=Microsoft.eShopOnContainers.Services.MarketingDb;User Id=sa;Password=Pass@word
62+
- identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105.
63+
ports:
64+
- "5110:80"
65+
5766
webspa:
5867
environment:
5968
- ASPNETCORE_ENVIRONMENT=Production

docker-compose.vs.debug.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,22 @@ services:
6161
labels:
6262
- "com.microsoft.visualstudio.targetoperatingsystem=linux"
6363

64+
marketing.api:
65+
image: eshop/marketing.api:dev
66+
build:
67+
args:
68+
source: ${DOCKER_BUILD_SOURCE}
69+
environment:
70+
- DOTNET_USE_POLLING_FILE_WATCHER=1
71+
volumes:
72+
- ./src/Services/Marketing/Marketing.API:/app
73+
- ~/.nuget/packages:/root/.nuget/packages:ro
74+
- ~/clrdbg:/clrdbg:ro
75+
entrypoint: tail -f /dev/null
76+
labels:
77+
- "com.microsoft.visualstudio.targetoperatingsystem=linux"
78+
79+
6480
webspa:
6581
image: eshop/webspa:dev
6682
build:
@@ -105,3 +121,4 @@ services:
105121
entrypoint: tail -f /dev/null
106122
labels:
107123
- "com.microsoft.visualstudio.targetoperatingsystem=linux"
124+

docker-compose.vs.release.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ services:
4141
labels:
4242
- "com.microsoft.visualstudio.targetoperatingsystem=linux"
4343

44+
marketing.api:
45+
build:
46+
args:
47+
source: ${DOCKER_BUILD_SOURCE}
48+
volumes:
49+
- ~/clrdbg:/clrdbg:ro
50+
entrypoint: tail -f /dev/null
51+
labels:
52+
- "com.microsoft.visualstudio.targetoperatingsystem=linux"
53+
4454
webspa:
4555
build:
4656
args:

docker-compose.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ services:
3636
depends_on:
3737
- sql.data
3838

39+
marketing.api:
40+
image: eshop/marketing.api
41+
build:
42+
context: ./src/Services/Marketing/Marketing.API
43+
dockerfile: Dockerfile
44+
depends_on:
45+
- sql.data
46+
- identity.api
47+
3948
webspa:
4049
image: eshop/webspa
4150
build:
@@ -74,4 +83,4 @@ services:
7483
build:
7584
context: ./src/Web/WebStatus
7685
dockerfile: Dockerfile
77-
86+

eShopOnContainers-ServicesAndWebApps.sln

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DataProtection", "DataProte
8080
EndProject
8181
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataProtection", "src\BuildingBlocks\DataProtection\DataProtection\DataProtection.csproj", "{23A33F9B-7672-426D-ACF9-FF8436ADC81A}"
8282
EndProject
83+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Marketing", "Marketing", "{A5260DE0-1FDD-467E-9CC1-A028AB081CEE}"
84+
EndProject
85+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Marketing.API", "src\Services\Marketing\Marketing.API\Marketing.API.csproj", "{DF395F85-B010-465D-857A-7EBCC512C0C2}"
86+
EndProject
8387
Global
8488
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8589
Ad-Hoc|Any CPU = Ad-Hoc|Any CPU
@@ -1054,6 +1058,54 @@ Global
10541058
{23A33F9B-7672-426D-ACF9-FF8436ADC81A}.Release|x64.Build.0 = Release|Any CPU
10551059
{23A33F9B-7672-426D-ACF9-FF8436ADC81A}.Release|x86.ActiveCfg = Release|Any CPU
10561060
{23A33F9B-7672-426D-ACF9-FF8436ADC81A}.Release|x86.Build.0 = Release|Any CPU
1061+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
1062+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
1063+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
1064+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
1065+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
1066+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
1067+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
1068+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
1069+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
1070+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
1071+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
1072+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
1073+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
1074+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.AppStore|Any CPU.Build.0 = Debug|Any CPU
1075+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.AppStore|ARM.ActiveCfg = Debug|Any CPU
1076+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.AppStore|ARM.Build.0 = Debug|Any CPU
1077+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
1078+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.AppStore|iPhone.Build.0 = Debug|Any CPU
1079+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
1080+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
1081+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.AppStore|x64.ActiveCfg = Debug|Any CPU
1082+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.AppStore|x64.Build.0 = Debug|Any CPU
1083+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.AppStore|x86.ActiveCfg = Debug|Any CPU
1084+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.AppStore|x86.Build.0 = Debug|Any CPU
1085+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1086+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
1087+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Debug|ARM.ActiveCfg = Debug|Any CPU
1088+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Debug|ARM.Build.0 = Debug|Any CPU
1089+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Debug|iPhone.ActiveCfg = Debug|Any CPU
1090+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Debug|iPhone.Build.0 = Debug|Any CPU
1091+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
1092+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
1093+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Debug|x64.ActiveCfg = Debug|Any CPU
1094+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Debug|x64.Build.0 = Debug|Any CPU
1095+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Debug|x86.ActiveCfg = Debug|Any CPU
1096+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Debug|x86.Build.0 = Debug|Any CPU
1097+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
1098+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Release|Any CPU.Build.0 = Release|Any CPU
1099+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Release|ARM.ActiveCfg = Release|Any CPU
1100+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Release|ARM.Build.0 = Release|Any CPU
1101+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Release|iPhone.ActiveCfg = Release|Any CPU
1102+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Release|iPhone.Build.0 = Release|Any CPU
1103+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
1104+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
1105+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Release|x64.ActiveCfg = Release|Any CPU
1106+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Release|x64.Build.0 = Release|Any CPU
1107+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Release|x86.ActiveCfg = Release|Any CPU
1108+
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Release|x86.Build.0 = Release|Any CPU
10571109
EndGlobalSection
10581110
GlobalSection(SolutionProperties) = preSolution
10591111
HideSolutionNode = FALSE
@@ -1090,6 +1142,8 @@ Global
10901142
{22A0F9C1-2D4A-4107-95B7-8459E6688BC5} = {A81ECBC2-6B00-4DCD-8388-469174033379}
10911143
{4BD76717-3102-4969-8C2C-BAAA3F0263B6} = {A81ECBC2-6B00-4DCD-8388-469174033379}
10921144
{89D80DF1-32E1-4AAF-970F-DA0AA6881F9D} = {807BB76E-B2BB-47A2-A57B-3D1B20FF5E7F}
1145+
{A5260DE0-1FDD-467E-9CC1-A028AB081CEE} = {91CF7717-08AB-4E65-B10E-0B426F01E2E8}
1146+
{DF395F85-B010-465D-857A-7EBCC512C0C2} = {A5260DE0-1FDD-467E-9CC1-A028AB081CEE}
10931147
{88B22DBB-AA8F-4290-A454-2C109352C345} = {DB0EFB20-B024-4E5E-A75C-52143C131D25}
10941148
{23A33F9B-7672-426D-ACF9-FF8436ADC81A} = {88B22DBB-AA8F-4290-A454-2C109352C345}
10951149
EndGlobalSection

src/Services/Identity/Identity.API/Configuration/Config.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ public static IEnumerable<ApiResource> GetApis()
1212
return new List<ApiResource>
1313
{
1414
new ApiResource("orders", "Orders Service"),
15-
new ApiResource("basket", "Basket Service")
15+
new ApiResource("basket", "Basket Service"),
16+
new ApiResource("marketing", "Marketing Service")
1617
};
1718
}
1819

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*
2+
!obj/Docker/publish/*
3+
!obj/Docker/empty/
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
namespace Microsoft.eShopOnContainers.Services.Marketing.API.Controllers
2+
{
3+
using Microsoft.AspNetCore.Mvc;
4+
using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure;
5+
using System.Threading.Tasks;
6+
using Microsoft.eShopOnContainers.Services.Marketing.API.Model;
7+
using Microsoft.EntityFrameworkCore;
8+
using Microsoft.eShopOnContainers.Services.Marketing.API.Dto;
9+
using System.Collections.Generic;
10+
using Microsoft.AspNetCore.Authorization;
11+
12+
[Route("api/v1/[controller]")]
13+
[Authorize]
14+
public class CampaignsController : Controller
15+
{
16+
private readonly MarketingContext _context;
17+
18+
public CampaignsController(MarketingContext context)
19+
{
20+
_context = context;
21+
}
22+
23+
[HttpGet]
24+
public async Task<IActionResult> GetAllCampaigns()
25+
{
26+
var campaignList = await _context.Campaigns
27+
.ToListAsync();
28+
29+
if (campaignList is null)
30+
{
31+
return Ok();
32+
}
33+
34+
var campaignDtoList = MapCampaignModelListToDtoList(campaignList);
35+
36+
return Ok(campaignDtoList);
37+
}
38+
39+
[HttpGet("{id:int}")]
40+
public async Task<IActionResult> GetCampaignById(int id)
41+
{
42+
var campaign = await _context.Campaigns
43+
.SingleOrDefaultAsync(c => c.Id == id);
44+
45+
if (campaign is null)
46+
{
47+
return NotFound();
48+
}
49+
50+
var campaignDto = MapCampaignModelToDto(campaign);
51+
52+
return Ok(campaignDto);
53+
}
54+
55+
[HttpPost]
56+
public async Task<IActionResult> CreateCampaign([FromBody] CampaignDTO campaignDto)
57+
{
58+
if (campaignDto is null)
59+
{
60+
return BadRequest();
61+
}
62+
63+
var campaign = MapCampaignDtoToModel(campaignDto);
64+
65+
await _context.Campaigns.AddAsync(campaign);
66+
await _context.SaveChangesAsync();
67+
68+
return CreatedAtAction(nameof(GetCampaignById), new { id = campaign.Id }, null);
69+
}
70+
71+
[HttpPut("{id:int}")]
72+
public async Task<IActionResult> UpdateCampaign(int id, [FromBody] CampaignDTO campaignDto)
73+
{
74+
if (id < 1 || campaignDto is null)
75+
{
76+
return BadRequest();
77+
}
78+
79+
var campaignToUpdate = await _context.Campaigns.FindAsync(id);
80+
if (campaignToUpdate is null)
81+
{
82+
return NotFound();
83+
}
84+
85+
campaignToUpdate.Description = campaignDto.Description;
86+
campaignToUpdate.From = campaignDto.From;
87+
campaignToUpdate.To = campaignDto.To;
88+
campaignToUpdate.Url = campaignDto.Url;
89+
90+
await _context.SaveChangesAsync();
91+
92+
return CreatedAtAction(nameof(GetCampaignById), new { id = campaignToUpdate.Id }, null);
93+
}
94+
95+
[HttpDelete("{id:int}")]
96+
public async Task<IActionResult> Delete(int id)
97+
{
98+
if (id < 1)
99+
{
100+
return BadRequest();
101+
}
102+
103+
var campaignToDelete = await _context.Campaigns.FindAsync(id);
104+
if (campaignToDelete is null)
105+
{
106+
return NotFound();
107+
}
108+
109+
_context.Campaigns.Remove(campaignToDelete);
110+
await _context.SaveChangesAsync();
111+
112+
return NoContent();
113+
}
114+
115+
116+
117+
private List<CampaignDTO> MapCampaignModelListToDtoList(List<Campaign> campaignList)
118+
{
119+
var campaignDtoList = new List<CampaignDTO>();
120+
121+
campaignList.ForEach(campaign => campaignDtoList
122+
.Add(MapCampaignModelToDto(campaign)));
123+
124+
return campaignDtoList;
125+
}
126+
127+
private CampaignDTO MapCampaignModelToDto(Campaign campaign)
128+
{
129+
return new CampaignDTO
130+
{
131+
Id = campaign.Id,
132+
Description = campaign.Description,
133+
From = campaign.From,
134+
To = campaign.To,
135+
Url = campaign.Url,
136+
};
137+
}
138+
139+
private Campaign MapCampaignDtoToModel(CampaignDTO campaignDto)
140+
{
141+
return new Campaign
142+
{
143+
Id = campaignDto.Id,
144+
Description = campaignDto.Description,
145+
From = campaignDto.From,
146+
To = campaignDto.To,
147+
Url = campaignDto.Url
148+
};
149+
}
150+
}
151+
}

0 commit comments

Comments
 (0)