Beispiel #1
0
        public static void ValidateBreakType(this IMetadataRepository repository, IReadOnlyCollection <string> breaks)
        {
            if (repository is null)
            {
                throw new ArgumentNullException(nameof(repository));
            }

            if (breaks == null || breaks.Count == 0 || breaks.Any(string.IsNullOrWhiteSpace))
            {
                throw new DataSyncException(DataSyncErrorCode.InvalidBreakType);
            }

            var metadataList =
                repository.GetByKey(MetaDataKeys.BreakTypes)
                .Select(s => s.Value.ToString())
                .ToArray();

            ValidateBreakType(metadataList, breaks);
        }
Beispiel #2
0
        public OutputImmutableDataSnapshot(RunWithScenarioReference runWithScenarioRef, IRunRepository runRepository,
                                           IScenarioRepository scenarioRepository, IPassRepository passRepository,
                                           ICampaignRepository campaignRepository, IScheduleRepository scheduleRepository,
                                           ISalesAreaRepository salesAreaRepository, IDemographicRepository demographicRepository,
                                           IProgrammeDictionaryRepository programmeDictionaryRepository, ISpotRepository spotRepository,
                                           IMetadataRepository metadataRepository)
        {
            var runStartDate = new Lazy <DateTime>(() => Run.Value.StartDate.Add(Run.Value.StartTime));
            var runEndDate   = new Lazy <DateTime>(() => DateHelper.ConvertBroadcastToStandard(Run.Value.EndDate, Run.Value.EndTime));

            Run                      = new Lazy <Run>(() => runRepository.Find(runWithScenarioRef.RunId));
            Scenario                 = new Lazy <Scenario>(() => scenarioRepository.Get(runWithScenarioRef.ScenarioId), true);
            ScenarioPasses           = new Lazy <IEnumerable <Pass> >(() => passRepository.FindByScenarioId(runWithScenarioRef.ScenarioId), true);
            AllCampaigns             = new Lazy <IEnumerable <Campaign> >(campaignRepository.GetAll, true);
            AllSalesAreas            = new Lazy <IEnumerable <SalesArea> >(salesAreaRepository.GetAll, true);
            AllDemographics          = new Lazy <IEnumerable <Demographic> >(demographicRepository.GetAll, true);
            AllProgrammeDictionaries = new Lazy <IEnumerable <ProgrammeDictionary> >(programmeDictionaryRepository.GetAll, true);
            BreakTypes               = new Lazy <IEnumerable <string> >(() => metadataRepository.GetByKey(MetaDataKeys.BreakTypes).Select(e => (string)e.Value));

            SpotsForRun = new Lazy <IEnumerable <Spot> >(() =>
            {
                var salesAreaPriorities = Run.Value.SalesAreaPriorities.Count == 0
                    ? AllSalesAreas.Value
                    : AllSalesAreas.Value.Where(sa => Run.Value.SalesAreaPriorities.Find(rsa => rsa.SalesArea == sa.Name) != null);

                return(spotRepository.Search(
                           runStartDate.Value,
                           runEndDate.Value,
                           salesAreaPriorities.Select(sa => sa.Name).ToList()
                           ));
            },
                                                         true
                                                         );

            BreaksForRun = new Lazy <IEnumerable <BreakSimple> >(() =>
                                                                 scheduleRepository.GetScheduleSimpleBreaks(
                                                                     AllSalesAreas.Value.Select(c => c.Name).ToList(),
                                                                     runStartDate.Value,
                                                                     runEndDate.Value
                                                                     ),
                                                                 true
                                                                 );
        }
Beispiel #3
0
        public IHttpActionResult Get([FromUri] MetaDataKeys key)
        {
            List <Data> metadata = null;

            if (key == MetaDataKeys.ProgramCategories)
            {
                var programmeCategories = _programmeCategoryHierarchyRepository.GetAll().ToList();
                if (programmeCategories.Any())
                {
                    metadata = new List <Data>(programmeCategories.Select(programmeCategory => new Data {
                        Id = programmeCategory.Id, Value = programmeCategory.Name
                    }));
                }
            }
            else
            {
                metadata = _metadataRepository.GetByKey(key);
            }
            return(metadata == null || !metadata.Any()  ? this.NoContent() : Ok(metadata));
        }