Beispiel #1
0
        public IHttpActionResult Validate()
        {
            // validate exisiting clash from DB
            var allclash = _clashRepository.GetAll()?.ToList();

            ClashRequiredValidation(allclash);
            ClashHelper.ValidateClashes(allclash);
            return(Ok());
        }
Beispiel #2
0
        /// <summary>Prepares the related data.</summary>
        /// <param name="campaigns">The campaigns.</param>
        protected override void PrepareRelatedData(IReadOnlyCollection <Campaign> campaigns)
        {
            var productExternalIds = campaigns.Select(c => c.Product).Where(s => !string.IsNullOrWhiteSpace(s))
                                     .Distinct(StringComparer.OrdinalIgnoreCase).ToList().ToList();

            _products = _productRepository.FindByExternal(productExternalIds).ToDictionary(x => x.Externalidentifier);

            var allClashes = _clashRepository.GetAll().IndexListByExternalRef();

            _clashRoots = ClashHelper.CalculateClashTopParents(allClashes);
        }
Beispiel #3
0
        private static AgSpotsSerialization ToAgSpot(
            List <Spot> spots,
            List <SalesArea> salesAreas,
            IReadOnlyCollection <BreakWithProgramme> breaks,
            List <Campaign> campaigns,
            List <Demographic> demographics,
            List <BusinessType> businessTypes,
            List <Product> products,
            List <Clash> clashes,
            AgSpot agSpot,
            IFeatureManager featureManager)
        {
            var agSpots = new ConcurrentBag <AgSpot>();

            Dictionary <string, SalesArea> salesAreasByName               = SalesArea.IndexListByName(salesAreas);
            Dictionary <string, Campaign>  campaignsByExternalId          = Campaign.IndexListByExternalId(campaigns);
            Dictionary <string, bool>      businessTypesInclusionSettings = businessTypes
                                                                            .ToDictionary(bt => bt.Code, bt => bt.IncludeConversionIndex);
            Dictionary <string, BreakWithProgramme> breaksWithProgrammeBySalesAreaAndExternalBreakRef = BreakWithProgramme.IndexListBySalesAreaAndExternalBreakRef(breaks);
            IImmutableDictionary <string, Product>  productByExternalId = products.IndexListByExternalID();
            IImmutableDictionary <string, Clash>    clashByExternalRef  = clashes.IndexListByExternalRef();

            var clashRoots = ClashHelper.CalculateClashTopParents(clashByExternalRef);

            var threadSafeSpotsCollection = spots.ToImmutableList();
            var includeNominalPrice       = featureManager.IsEnabled(nameof(ProductFeature.NominalPrice));
            var includePositionInBreak    = featureManager.IsEnabled(nameof(ProductFeature.PositionInBreak));

            _ = Parallel.ForEach(threadSafeSpotsCollection, spot => agSpots.Add(
                                     GetAgSpot(
                                         spot,
                                         threadSafeSpotsCollection,
                                         salesAreasByName,
                                         campaignsByExternalId,
                                         businessTypesInclusionSettings,
                                         breaksWithProgrammeBySalesAreaAndExternalBreakRef,
                                         productByExternalId,
                                         clashByExternalRef,
                                         demographics,
                                         agSpot.Clone(),
                                         includeNominalPrice,
                                         includePositionInBreak,
                                         clashRoots
                                         )
                                     )
                                 );

            var serialization = new AgSpotsSerialization();

            return(serialization.MapFrom(agSpots.ToList()));
        }
 // GET api/clash/12345
 public War Get(string id)
 {
     return(ClashHelper.GetWar(id));
 }
Beispiel #5
0
 private void Validation(List <Clash> newClashes, List <Clash> clashes)
 {
     ClashRequiredValidation(newClashes);
     ClashHelper.ValidateClashes(newClashes, clashes);
 }
Beispiel #6
0
 public void Post([FromBody] Update warUpdate)
 {
     var result = ClashHelper.SetCalledTarget(warUpdate.Id.ToLower(), warUpdate.PlayerName, warUpdate.Rank, warUpdate.PositionInLine);
 }