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