Browse Source

Create GetCampaignByUserId in CampaignsController

pull/223/head
Christian Arenas 7 years ago
parent
commit
432994d113
2 changed files with 33 additions and 0 deletions
  1. +21
    -0
      src/Services/Marketing/Marketing.API/Controllers/CampaignsController.cs
  2. +12
    -0
      src/Services/Marketing/Marketing.API/Dto/UserLocationDTO.cs

+ 21
- 0
src/Services/Marketing/Marketing.API/Controllers/CampaignsController.cs View File

@ -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
- 0
src/Services/Marketing/Marketing.API/Dto/UserLocationDTO.cs View 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…
Cancel
Save