Merge branch 'feature/marketing-read-model-data' into marketingcampaign
# Conflicts: # src/Services/Location/Locations.API/Model/Locations.cs
This commit is contained in:
commit
aae16d095e
@ -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; }
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,8 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[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,
|
public IActionResult GetLocationByCampaignAndLocationRuleId(int campaignId,
|
||||||
int userLocationRuleId)
|
int userLocationRuleId)
|
||||||
{
|
{
|
||||||
@ -83,7 +84,7 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Controllers
|
|||||||
await _context.Rules.AddAsync(locationRule);
|
await _context.Rules.AddAsync(locationRule);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
return CreatedAtAction(nameof(GetLocationByCampaignAndLocationRuleId),
|
return CreatedAtRoute(nameof(GetLocationByCampaignAndLocationRuleId),
|
||||||
new { campaignId = campaignId, locationRuleId = locationRule.Id }, null);
|
new { campaignId = campaignId, locationRuleId = locationRule.Id }, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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; }
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
{
|
{
|
||||||
"ConnectionString": "Server=tcp:127.0.0.1,5433;Initial Catalog=Microsoft.eShopOnContainers.Services.MarketingDb;User Id=sa;Password=Pass@word",
|
"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",
|
"IdentityUrl": "http://localhost:5105",
|
||||||
"isTest": "true"
|
"isTest": "true",
|
||||||
|
"EventBusConnection": "localhost"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user