Browse Source

Create a LocationId in data read model and change the affected modification

pull/223/head
Christian Arenas 7 years ago
parent
commit
f1ccc24c85
9 changed files with 18 additions and 15 deletions
  1. +1
    -1
      src/Services/Location/Locations.API/Controllers/LocationsController.cs
  2. +8
    -4
      src/Services/Location/Locations.API/Infrastructure/LocationsContextSeed.cs
  3. +1
    -1
      src/Services/Location/Locations.API/Infrastructure/Repositories/ILocationsRepository.cs
  4. +2
    -2
      src/Services/Location/Locations.API/Infrastructure/Repositories/LocationsRepository.cs
  5. +1
    -1
      src/Services/Location/Locations.API/Infrastructure/Services/ILocationsService.cs
  6. +2
    -2
      src/Services/Location/Locations.API/Infrastructure/Services/LocationsService.cs
  7. +1
    -1
      src/Services/Location/Locations.API/Model/UserLocationDetails.cs
  8. +1
    -2
      src/Services/Marketing/Marketing.API/Model/Location.cs
  9. +1
    -1
      src/Services/Marketing/Marketing.API/Model/UserLocationDetails.cs

+ 1
- 1
src/Services/Location/Locations.API/Controllers/LocationsController.cs View File

@ -41,7 +41,7 @@ namespace Locations.API.Controllers
//GET api/v1/[controller]/1 //GET api/v1/[controller]/1
[Route("{locationId}")] [Route("{locationId}")]
[HttpGet] [HttpGet]
public async Task<IActionResult> GetLocation(string locationId)
public async Task<IActionResult> GetLocation(int locationId)
{ {
var location = await _locationsService.GetLocation(locationId); var location = await _locationsService.GetLocation(locationId);
return Ok(location); return Ok(location);


+ 8
- 4
src/Services/Location/Locations.API/Infrastructure/LocationsContextSeed.cs View File

@ -32,7 +32,8 @@
var us = new Locations() var us = new Locations()
{ {
Code = "US", Code = "US",
Description = "United States"
Description = "United States",
LocationId = 1
}; };
us.SetLocation(-101.357386, 41.650455); us.SetLocation(-101.357386, 41.650455);
us.SetArea(GetUSPoligon()); us.SetArea(GetUSPoligon());
@ -46,7 +47,8 @@
{ {
Parent_Id = parentId, Parent_Id = parentId,
Code = "WHT", Code = "WHT",
Description = "Washington"
Description = "Washington",
LocationId = 2
}; };
wht.SetLocation(-119.542781, 47.223652); wht.SetLocation(-119.542781, 47.223652);
wht.SetArea(GetWashingtonPoligon()); wht.SetArea(GetWashingtonPoligon());
@ -61,7 +63,8 @@
{ {
Parent_Id = parentId, Parent_Id = parentId,
Code = "SEAT", Code = "SEAT",
Description = "Seattle"
Description = "Seattle",
LocationId = 3
}; };
stl.SetArea(GetSeattlePoligon()); stl.SetArea(GetSeattlePoligon());
stl.SetLocation(-122.330747, 47.603111); stl.SetLocation(-122.330747, 47.603111);
@ -74,7 +77,8 @@
{ {
Parent_Id = parentId, Parent_Id = parentId,
Code = "REDM", Code = "REDM",
Description = "Redmond"
Description = "Redmond",
LocationId = 4
}; };
rdm.SetLocation(-122.122887, 47.674961); rdm.SetLocation(-122.122887, 47.674961);
rdm.SetArea(GetRedmondPoligon()); rdm.SetArea(GetRedmondPoligon());


+ 1
- 1
src/Services/Location/Locations.API/Infrastructure/Repositories/ILocationsRepository.cs View File

@ -7,7 +7,7 @@
public interface ILocationsRepository public interface ILocationsRepository
{ {
Task<Locations> GetAsync(string locationId);
Task<Locations> GetAsync(int locationId);
Task<List<Locations>> GetLocationListAsync(); Task<List<Locations>> GetLocationListAsync();


+ 2
- 2
src/Services/Location/Locations.API/Infrastructure/Repositories/LocationsRepository.cs View File

@ -20,9 +20,9 @@
_context = new LocationsContext(settings); _context = new LocationsContext(settings);
} }
public async Task<Locations> GetAsync(string locationId)
public async Task<Locations> GetAsync(int locationId)
{ {
var filter = Builders<Locations>.Filter.Eq("Id", ObjectId.Parse(locationId));
var filter = Builders<Locations>.Filter.Eq("LocationId", locationId);
return await _context.Locations return await _context.Locations
.Find(filter) .Find(filter)
.FirstOrDefaultAsync(); .FirstOrDefaultAsync();


+ 1
- 1
src/Services/Location/Locations.API/Infrastructure/Services/ILocationsService.cs View File

@ -7,7 +7,7 @@
public interface ILocationsService public interface ILocationsService
{ {
Task<Locations> GetLocation(string locationId);
Task<Locations> GetLocation(int locationId);
Task<UserLocation> GetUserLocation(string id); Task<UserLocation> GetUserLocation(string id);


+ 2
- 2
src/Services/Location/Locations.API/Infrastructure/Services/LocationsService.cs View File

@ -22,7 +22,7 @@
_eventBus = eventBus ?? throw new ArgumentNullException(nameof(eventBus)); _eventBus = eventBus ?? throw new ArgumentNullException(nameof(eventBus));
} }
public async Task<Locations> GetLocation(string locationId)
public async Task<Locations> GetLocation(int locationId)
{ {
return await _locationsRepository.GetAsync(locationId); return await _locationsRepository.GetAsync(locationId);
} }
@ -76,7 +76,7 @@
newLocations.ForEach(location => { newLocations.ForEach(location => {
result.Add(new UserLocationDetails() result.Add(new UserLocationDetails()
{ {
LocationId = location.Id,
LocationId = location.LocationId,
Code = location.Code, Code = location.Code,
Description = location.Description Description = location.Description
}); });


+ 1
- 1
src/Services/Location/Locations.API/Model/UserLocationDetails.cs View File

@ -7,7 +7,7 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API.Model
{ {
public class UserLocationDetails public class UserLocationDetails
{ {
public string LocationId { get; set; }
public int LocationId { get; set; }
public string Code { get; set; } public string Code { get; set; }
public string Description { get; set; } public string Description { get; set; }
} }


+ 1
- 2
src/Services/Marketing/Marketing.API/Model/Location.cs View File

@ -9,8 +9,7 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Model
{ {
public class Location public class Location
{ {
[BsonRepresentation(BsonType.ObjectId)]
public string LocationId { get; set; }
public int LocationId { get; set; }
public string Code { get; set; } public string Code { get; set; }
public string Description { get; set; } public string Description { get; set; }
} }


+ 1
- 1
src/Services/Marketing/Marketing.API/Model/UserLocationDetails.cs View File

@ -2,7 +2,7 @@
{ {
public class UserLocationDetails public class UserLocationDetails
{ {
public string LocationId { get; set; }
public int LocationId { get; set; }
public string Code { get; set; } public string Code { get; set; }
public string Description { get; set; } public string Description { get; set; }
} }


Loading…
Cancel
Save