Create GetCampaignByUserId in CampaignsController
This commit is contained in:
parent
4a60d97d4d
commit
432994d113
@ -8,6 +8,10 @@
|
||||
using Microsoft.eShopOnContainers.Services.Marketing.API.Dto;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
|
||||
[Route("api/v1/[controller]")]
|
||||
[Authorize]
|
||||
@ -112,6 +116,23 @@
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
[HttpGet("user/{userId:guid}")]
|
||||
public async Task<IActionResult> GetCampaignByUserId(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 userLocationRule = await _context.Rules.OfType<UserLocationRule>().Include(c => c.Campaign)
|
||||
.FirstOrDefaultAsync(c => c.LocationId == userLocationDto.LocationId);
|
||||
|
||||
return Ok(userLocationRule.Campaign);
|
||||
}
|
||||
|
||||
|
||||
private List<CampaignDTO> MapCampaignModelListToDtoList(List<Campaign> campaignList)
|
||||
|
12
src/Services/Marketing/Marketing.API/Dto/UserLocationDTO.cs
Normal file
12
src/Services/Marketing/Marketing.API/Dto/UserLocationDTO.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
namespace Microsoft.eShopOnContainers.Services.Marketing.API.Dto
|
||||
{
|
||||
public class UserLocationDTO
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public int LocationId { get; set; }
|
||||
public DateTime UpdateDate { get; set; }
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user