dev merge
This commit is contained in:
parent
85c9af690f
commit
d9db0a65f2
@ -7,12 +7,12 @@
|
|||||||
using AspNetCore.Mvc;
|
using AspNetCore.Mvc;
|
||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Catalog.API.ViewModel;
|
|
||||||
using Model;
|
using Model;
|
||||||
using EntityFrameworkCore;
|
using EntityFrameworkCore;
|
||||||
using Dto;
|
using Dto;
|
||||||
using AspNetCore.Authorization;
|
using AspNetCore.Authorization;
|
||||||
using Extensions.Options;
|
using Extensions.Options;
|
||||||
|
using Microsoft.eShopOnContainers.Services.Marketing.API.ViewModel;
|
||||||
|
|
||||||
[Route("api/v1/[controller]")]
|
[Route("api/v1/[controller]")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
@ -129,30 +129,26 @@
|
|||||||
{
|
{
|
||||||
var marketingData = await _marketingDataRepository.GetAsync(userId.ToString());
|
var marketingData = await _marketingDataRepository.GetAsync(userId.ToString());
|
||||||
|
|
||||||
if (marketingData is null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
var campaignDtoList = new List<CampaignDTO>();
|
var campaignDtoList = new List<CampaignDTO>();
|
||||||
|
|
||||||
//Get User Location Campaign
|
if (marketingData != null)
|
||||||
foreach (var userLocation in marketingData.Locations)
|
|
||||||
{
|
{
|
||||||
|
var locationIdCandidateList = marketingData.Locations.Select(x => x.LocationId);
|
||||||
var userCampaignList = await _context.Rules
|
var userCampaignList = await _context.Rules
|
||||||
.OfType<UserLocationRule>()
|
.OfType<UserLocationRule>()
|
||||||
.Include(c => c.Campaign)
|
.Include(c => c.Campaign)
|
||||||
.Where(c => c.Campaign.From <= DateTime.Now
|
.Where(c => c.Campaign.From <= DateTime.Now
|
||||||
&& c.Campaign.To >= DateTime.Now
|
&& c.Campaign.To >= DateTime.Now
|
||||||
&& c.LocationId == userLocation.LocationId)
|
&& locationIdCandidateList.Contains(c.LocationId))
|
||||||
.Select(c => c.Campaign)
|
.Select(c => c.Campaign)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
if (userCampaignList != null && userCampaignList.Any())
|
if (userCampaignList != null && userCampaignList.Any())
|
||||||
{
|
{
|
||||||
var userCampaignDtoList = MapCampaignModelListToDtoList(userCampaignList);
|
var userCampaignDtoList = MapCampaignModelListToDtoList(userCampaignList);
|
||||||
campaignDtoList.AddRange(userCampaignDtoList);
|
campaignDtoList.AddRange(userCampaignDtoList);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var totalItems = campaignDtoList.Count();
|
var totalItems = campaignDtoList.Count();
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Services.Catalog.API.ViewModel
|
namespace Microsoft.eShopOnContainers.Services.Marketing.API.ViewModel
|
||||||
{
|
{
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
|
||||||
public class PaginatedItemsViewModel<TEntity> where TEntity : class
|
public class PaginatedItemsViewModel<TEntity> where TEntity : class
|
||||||
{
|
{
|
||||||
public int PageIndex { get; private set; }
|
public int PageIndex { get; private set; }
|
||||||
@ -21,4 +20,4 @@
|
|||||||
this.Data = data;
|
this.Data = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,6 +10,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System;
|
using System;
|
||||||
using ViewModels.Pagination;
|
using ViewModels.Pagination;
|
||||||
|
using global::WebMVC.ViewModels;
|
||||||
|
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public class CampaignsController : Controller
|
public class CampaignsController : Controller
|
||||||
|
Loading…
x
Reference in New Issue
Block a user