Skip to content

Commit b3e5362

Browse files
committed
Merge branch 'feature/marketing-read-model-data' into marketingcampaign
# Conflicts: # src/Services/Location/Locations.API/Model/Locations.cs
2 parents 13a201b + 4ba9d66 commit b3e5362

11 files changed

Lines changed: 25 additions & 18 deletions

File tree

src/Services/Location/Locations.API/Controllers/LocationsController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public async Task<IActionResult> GetAllLocations()
4141
//GET api/v1/[controller]/1
4242
[Route("{locationId}")]
4343
[HttpGet]
44-
public async Task<IActionResult> GetLocation(string locationId)
44+
public async Task<IActionResult> GetLocation(int locationId)
4545
{
4646
var location = await _locationsService.GetLocation(locationId);
4747
return Ok(location);

src/Services/Location/Locations.API/Infrastructure/LocationsContextSeed.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ static async Task SetUSLocations()
3232
var us = new Locations()
3333
{
3434
Code = "US",
35-
Description = "United States"
35+
Description = "United States",
36+
LocationId = 1
3637
};
3738
us.SetLocation(-101.357386, 41.650455);
3839
us.SetArea(GetUSPoligon());
@@ -46,7 +47,8 @@ static async Task SetWashingtonLocations(string parentId)
4647
{
4748
Parent_Id = parentId,
4849
Code = "WHT",
49-
Description = "Washington"
50+
Description = "Washington",
51+
LocationId = 2
5052
};
5153
wht.SetLocation(-119.542781, 47.223652);
5254
wht.SetArea(GetWashingtonPoligon());
@@ -61,7 +63,8 @@ static async Task SetSeattleLocations(string parentId)
6163
{
6264
Parent_Id = parentId,
6365
Code = "SEAT",
64-
Description = "Seattle"
66+
Description = "Seattle",
67+
LocationId = 3
6568
};
6669
stl.SetArea(GetSeattlePoligon());
6770
stl.SetLocation(-122.330747, 47.603111);
@@ -74,7 +77,8 @@ static async Task SetRedmondLocations(string parentId)
7477
{
7578
Parent_Id = parentId,
7679
Code = "REDM",
77-
Description = "Redmond"
80+
Description = "Redmond",
81+
LocationId = 4
7882
};
7983
rdm.SetLocation(-122.122887, 47.674961);
8084
rdm.SetArea(GetRedmondPoligon());

src/Services/Location/Locations.API/Infrastructure/Repositories/ILocationsRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
public interface ILocationsRepository
99
{
10-
Task<Locations> GetAsync(string locationId);
10+
Task<Locations> GetAsync(int locationId);
1111

1212
Task<List<Locations>> GetLocationListAsync();
1313

src/Services/Location/Locations.API/Infrastructure/Repositories/LocationsRepository.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ public LocationsRepository(IOptions<LocationSettings> settings)
2020
_context = new LocationsContext(settings);
2121
}
2222

23-
public async Task<Locations> GetAsync(string locationId)
23+
public async Task<Locations> GetAsync(int locationId)
2424
{
25-
var filter = Builders<Locations>.Filter.Eq("Id", ObjectId.Parse(locationId));
25+
var filter = Builders<Locations>.Filter.Eq("LocationId", locationId);
2626
return await _context.Locations
2727
.Find(filter)
2828
.FirstOrDefaultAsync();

src/Services/Location/Locations.API/Infrastructure/Services/ILocationsService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
public interface ILocationsService
99
{
10-
Task<Locations> GetLocation(string locationId);
10+
Task<Locations> GetLocation(int locationId);
1111

1212
Task<UserLocation> GetUserLocation(string id);
1313

src/Services/Location/Locations.API/Infrastructure/Services/LocationsService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public LocationsService(ILocationsRepository locationsRepository, IEventBus even
2222
_eventBus = eventBus ?? throw new ArgumentNullException(nameof(eventBus));
2323
}
2424

25-
public async Task<Locations> GetLocation(string locationId)
25+
public async Task<Locations> GetLocation(int locationId)
2626
{
2727
return await _locationsRepository.GetAsync(locationId);
2828
}
@@ -76,7 +76,7 @@ private List<UserLocationDetails> MapUserLocationDetails(List<Locations> newLoca
7676
newLocations.ForEach(location => {
7777
result.Add(new UserLocationDetails()
7878
{
79-
LocationId = location.Id,
79+
LocationId = location.LocationId,
8080
Code = location.Code,
8181
Description = location.Description
8282
});

src/Services/Location/Locations.API/Model/UserLocationDetails.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API.Model
77
{
88
public class UserLocationDetails
99
{
10-
public string LocationId { get; set; }
10+
public int LocationId { get; set; }
1111
public string Code { get; set; }
1212
public string Description { get; set; }
1313
}

src/Services/Marketing/Marketing.API/Controllers/LocationsController.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public LocationsController(MarketingContext context)
2020
}
2121

2222
[HttpGet]
23-
[Route("api/v1/campaigns/{campaignId:int}/locations/{userLocationRuleId:int}")]
23+
[Route("api/v1/campaigns/{campaignId:int}/locations/{userLocationRuleId:int}",
24+
Name = "GetLocationByCampaignAndLocationRuleId")]
2425
public IActionResult GetLocationByCampaignAndLocationRuleId(int campaignId,
2526
int userLocationRuleId)
2627
{
@@ -83,7 +84,7 @@ public async Task<IActionResult> CreateLocation(int campaignId,
8384
await _context.Rules.AddAsync(locationRule);
8485
await _context.SaveChangesAsync();
8586

86-
return CreatedAtAction(nameof(GetLocationByCampaignAndLocationRuleId),
87+
return CreatedAtRoute(nameof(GetLocationByCampaignAndLocationRuleId),
8788
new { campaignId = campaignId, locationRuleId = locationRule.Id }, null);
8889
}
8990

src/Services/Marketing/Marketing.API/Model/Location.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Model
99
{
1010
public class Location
1111
{
12-
[BsonRepresentation(BsonType.ObjectId)]
13-
public string LocationId { get; set; }
12+
public int LocationId { get; set; }
1413
public string Code { get; set; }
1514
public string Description { get; set; }
1615
}

src/Services/Marketing/Marketing.API/Model/UserLocationDetails.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
public class UserLocationDetails
44
{
5-
public string LocationId { get; set; }
5+
public int LocationId { get; set; }
66
public string Code { get; set; }
77
public string Description { get; set; }
88
}

0 commit comments

Comments
 (0)