File tree Expand file tree Collapse file tree
src/Services/Marketing/Marketing.API Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 using Microsoft . eShopOnContainers . Services . Marketing . API . Dto ;
99 using System . Collections . Generic ;
1010 using Microsoft . AspNetCore . Authorization ;
11+ using System ;
12+ using System . Net . Http ;
13+ using System . Linq ;
14+ using System . Net . Http . Headers ;
1115
1216 [ Route ( "api/v1/[controller]" ) ]
1317 [ Authorize ]
@@ -112,6 +116,23 @@ public async Task<IActionResult> Delete(int id)
112116 return NoContent ( ) ;
113117 }
114118
119+ [ HttpGet ( "user/{userId:guid}" ) ]
120+ public async Task < IActionResult > GetCampaignByUserId ( Guid userId )
121+ {
122+ //TODO: Call data read model to get userLocation from userId
123+ UserLocationDTO userLocationDto = new UserLocationDTO
124+ {
125+ Id = "test" ,
126+ LocationId = 1 ,
127+ UpdateDate = DateTime . Now ,
128+ UserId = userId
129+ } ;
130+
131+ var userLocationRule = await _context . Rules . OfType < UserLocationRule > ( ) . Include ( c => c . Campaign )
132+ . FirstOrDefaultAsync ( c => c . LocationId == userLocationDto . LocationId ) ;
133+
134+ return Ok ( userLocationRule . Campaign ) ;
135+ }
115136
116137
117138 private List < CampaignDTO > MapCampaignModelListToDtoList ( List < Campaign > campaignList )
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Collections . Generic ;
3+ namespace Microsoft . eShopOnContainers . Services . Marketing . API . Dto
4+ {
5+ public class UserLocationDTO
6+ {
7+ public string Id { get ; set ; }
8+ public Guid UserId { get ; set ; }
9+ public int LocationId { get ; set ; }
10+ public DateTime UpdateDate { get ; set ; }
11+ }
12+ }
You can’t perform that action at this time.
0 commit comments