Create a LocationId in data read model and change the affected modification
This commit is contained in:
parent
9bf5670020
commit
0ffa9cb981
@ -41,7 +41,7 @@ namespace Locations.API.Controllers
|
||||
//GET api/v1/[controller]/1
|
||||
[Route("{locationId}")]
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetLocation(string locationId)
|
||||
public async Task<IActionResult> GetLocation(int locationId)
|
||||
{
|
||||
var location = await _locationsService.GetLocation(locationId);
|
||||
return Ok(location);
|
||||
|
@ -32,7 +32,8 @@
|
||||
var us = new Locations()
|
||||
{
|
||||
Code = "US",
|
||||
Description = "United States"
|
||||
Description = "United States",
|
||||
LocationId = 1
|
||||
};
|
||||
us.SetLocation(-101.357386, 41.650455);
|
||||
us.SetArea(GetUSPoligon());
|
||||
@ -46,7 +47,8 @@
|
||||
{
|
||||
Parent_Id = parentId,
|
||||
Code = "WHT",
|
||||
Description = "Washington"
|
||||
Description = "Washington",
|
||||
LocationId = 2
|
||||
};
|
||||
wht.SetLocation(-119.542781, 47.223652);
|
||||
wht.SetArea(GetWashingtonPoligon());
|
||||
@ -61,7 +63,8 @@
|
||||
{
|
||||
Parent_Id = parentId,
|
||||
Code = "SEAT",
|
||||
Description = "Seattle"
|
||||
Description = "Seattle",
|
||||
LocationId = 3
|
||||
};
|
||||
stl.SetArea(GetSeattlePoligon());
|
||||
stl.SetLocation(-122.330747, 47.603111);
|
||||
@ -74,7 +77,8 @@
|
||||
{
|
||||
Parent_Id = parentId,
|
||||
Code = "REDM",
|
||||
Description = "Redmond"
|
||||
Description = "Redmond",
|
||||
LocationId = 4
|
||||
};
|
||||
rdm.SetLocation(-122.122887, 47.674961);
|
||||
rdm.SetArea(GetRedmondPoligon());
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
public interface ILocationsRepository
|
||||
{
|
||||
Task<Locations> GetAsync(string locationId);
|
||||
Task<Locations> GetAsync(int locationId);
|
||||
|
||||
Task<List<Locations>> GetLocationListAsync();
|
||||
|
||||
|
@ -20,9 +20,9 @@
|
||||
_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
|
||||
.Find(filter)
|
||||
.FirstOrDefaultAsync();
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
public interface ILocationsService
|
||||
{
|
||||
Task<Locations> GetLocation(string locationId);
|
||||
Task<Locations> GetLocation(int locationId);
|
||||
|
||||
Task<UserLocation> GetUserLocation(string id);
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
_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);
|
||||
}
|
||||
@ -76,7 +76,7 @@
|
||||
newLocations.ForEach(location => {
|
||||
result.Add(new UserLocationDetails()
|
||||
{
|
||||
LocationId = location.Id,
|
||||
LocationId = location.LocationId,
|
||||
Code = location.Code,
|
||||
Description = location.Description
|
||||
});
|
||||
|
@ -7,7 +7,7 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API.Model
|
||||
{
|
||||
public class UserLocationDetails
|
||||
{
|
||||
public string LocationId { get; set; }
|
||||
public int LocationId { get; set; }
|
||||
public string Code { get; set; }
|
||||
public string Description { get; set; }
|
||||
}
|
||||
|
@ -9,8 +9,7 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Model
|
||||
{
|
||||
public class Location
|
||||
{
|
||||
[BsonRepresentation(BsonType.ObjectId)]
|
||||
public string LocationId { get; set; }
|
||||
public int LocationId { get; set; }
|
||||
public string Code { get; set; }
|
||||
public string Description { get; set; }
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
{
|
||||
public class UserLocationDetails
|
||||
{
|
||||
public string LocationId { get; set; }
|
||||
public int LocationId { get; set; }
|
||||
public string Code { get; set; }
|
||||
public string Description { get; set; }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user