Add LocationId field to UserLocation and call GetAsync repository method from marketing controller
This commit is contained in:
parent
68dbc92172
commit
41654878a7
@ -10,8 +10,7 @@
|
||||
[BsonRepresentation(BsonType.ObjectId)]
|
||||
public string Id { get; set; }
|
||||
public string UserId { get; set; }
|
||||
[BsonRepresentation(BsonType.ObjectId)]
|
||||
public string LocationId { get; set; }
|
||||
public int LocationId { get; set; }
|
||||
public DateTime UpdateDate { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
namespace Microsoft.eShopOnContainers.Services.Marketing.API.Controllers
|
||||
{
|
||||
using Infrastructure.Repositories;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure;
|
||||
using System.Threading.Tasks;
|
||||
@ -18,10 +19,13 @@
|
||||
public class CampaignsController : Controller
|
||||
{
|
||||
private readonly MarketingContext _context;
|
||||
private readonly IMarketingDataRepository _marketingDataRepository;
|
||||
|
||||
public CampaignsController(MarketingContext context)
|
||||
public CampaignsController(MarketingContext context,
|
||||
IMarketingDataRepository marketingDataRepository)
|
||||
{
|
||||
_context = context;
|
||||
_marketingDataRepository = marketingDataRepository;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@ -117,19 +121,14 @@
|
||||
}
|
||||
|
||||
[HttpGet("user/{userId:guid}")]
|
||||
public async Task<IActionResult> GetCampaignByUserId(Guid userId)
|
||||
public async Task<IActionResult> GetCampaignsByUserId(Guid userId)
|
||||
{
|
||||
//TODO: Call data read model to get userLocation from userId
|
||||
UserLocationDTO userLocationDto = new UserLocationDTO
|
||||
{
|
||||
Id = "test",
|
||||
LocationId = 1,
|
||||
UpdateDate = DateTime.Now,
|
||||
UserId = userId
|
||||
};
|
||||
var userLocation = await _marketingDataRepository.GetAsync(userId.ToString());
|
||||
|
||||
var userLocationId = 1;
|
||||
|
||||
var userLocationRule = await _context.Rules.OfType<UserLocationRule>().Include(c => c.Campaign)
|
||||
.FirstOrDefaultAsync(c => c.LocationId == userLocationDto.LocationId);
|
||||
.FirstOrDefaultAsync(c => c.LocationId == userLocationId);
|
||||
|
||||
return Ok(userLocationRule.Campaign);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user