Merge branch 'feature/marketing-read-model-data' into marketingcampaign

# Conflicts:
#	src/Services/Location/Locations.API/Model/Locations.cs
This commit is contained in:
Christian Arenas 2017-06-14 16:26:28 +02:00
commit b3e5362865
11 changed files with 25 additions and 18 deletions

View File

@ -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);

View File

@ -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());

View File

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

View File

@ -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();

View File

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

View File

@ -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
});

View File

@ -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; }
}

View File

@ -20,7 +20,8 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Controllers
}
[HttpGet]
[Route("api/v1/campaigns/{campaignId:int}/locations/{userLocationRuleId:int}")]
[Route("api/v1/campaigns/{campaignId:int}/locations/{userLocationRuleId:int}",
Name = "GetLocationByCampaignAndLocationRuleId")]
public IActionResult GetLocationByCampaignAndLocationRuleId(int campaignId,
int userLocationRuleId)
{
@ -83,7 +84,7 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Controllers
await _context.Rules.AddAsync(locationRule);
await _context.SaveChangesAsync();
return CreatedAtAction(nameof(GetLocationByCampaignAndLocationRuleId),
return CreatedAtRoute(nameof(GetLocationByCampaignAndLocationRuleId),
new { campaignId = campaignId, locationRuleId = locationRule.Id }, null);
}

View File

@ -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; }
}

View File

@ -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; }
}

View File

@ -1,5 +1,8 @@
{
"ConnectionString": "Server=tcp:127.0.0.1,5433;Initial Catalog=Microsoft.eShopOnContainers.Services.MarketingDb;User Id=sa;Password=Pass@word",
"MongoConnectionString": "mongodb://localhost:27017",
"MongoDatabase": "MarketingDb",
"IdentityUrl": "http://localhost:5105",
"isTest": "true"
"isTest": "true",
"EventBusConnection": "localhost"
}