Beispiel #1
0
        public Task ExecuteAsync(Guid campaignId, CancellationToken cancellationToken = default)
        {
            _campaignRepository.Delete(campaignId);
            _campaignRepository.SaveChanges();

            var updated = false;

            foreach (var scenario in _scenarioRepository.GetLibraried())
            {
                if ((scenario.CampaignPassPriorities?.RemoveAll(x =>
                                                                !(x.Campaign is null) && x.Campaign.Uid == campaignId) ?? 0) > 0)
                {
                    _scenarioRepository.Update(scenario);
                    updated = true;
                }
            }

            if (updated)
            {
                _scenarioRepository.SaveChanges();
            }

            return(Task.CompletedTask);
        }
        private void GetAllScenariosAndCampaigns(
            out IEnumerable <Scenario> scenarios,
            out IList <CampaignWithProductFlatModel> allCampaigns)
        {
            scenarios = _scenarioRepository.GetLibraried();

            // Get all the campaigns with product info.
            // This will be used to add CampaignPassPriorities for new Campaigns
            // to each Scenario
            var campaignsResult = _campaignRepository.GetWithProduct(null);

            allCampaigns = (campaignsResult.Items != null && campaignsResult.Items.Count > 0) ?
                           campaignsResult.Items.ToList() :
                           null;
        }