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
|
//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);
|
||||||
|
@ -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());
|
||||||
|
@ -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();
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
@ -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
|
||||||
});
|
});
|
||||||
|
@ -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; }
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,7 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Model
|
|||||||
{
|
{
|
||||||
public class Location
|
public class Location
|
||||||
{
|
{
|
||||||
[BsonRepresentation(BsonType.ObjectId)]
|
public int LocationId { get; set; }
|
||||||
public string LocationId { get; set; }
|
|
||||||
public string Code { get; set; }
|
public string Code { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -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…
x
Reference in New Issue
Block a user