Esempio n. 1
0
        public IEnumerable <ProgrammeModel> Get()
        {
            var programmes = _programmeRepository.GetAll();

            if (programmes != null && programmes.Any())
            {
                return(_mapper.Map <List <ProgrammeModel> >(programmes.ToList()));
            }

            return(null);
        }
Esempio n. 2
0
        public Dictionary <string, int> Get()
        {
            var breakcount     = _breakrepo.GetAll().Count();
            var spotCountcount = _spotrepo.GetAll().Count();
            var progcount      = _programmerepo.GetAll().Count();
            var campaigncount  = _campaignrepo.GetAll().Count();
            var productcount   = _productRepository.GetAll().Count();
            var clashcount     = _clashRepository.GetAll().Count();

            var items = new Dictionary <string, int> {
                { "Breaks", breakcount }, { "Spots", spotCountcount }, { "Programmes", progcount }, { "Campaigns", campaigncount }, { "Product", productcount }, { "Clash", clashcount }
            };

            return(items);
        }
Esempio n. 3
0
        public override bool CompareTargetDataToDb(string key, string fileName = null, Table tableData = null, TestDataResultOperationType operationType = default)
        {
            var featureTestData = GenerateDataFromTable(tableData);
            var fileTestData    = GenerateDataFromFile(fileName, key);
            var programmes      = _programmeRepository.GetAll().ToList();

            switch (operationType)
            {
            case TestDataResultOperationType.Add:
            {
                featureTestData.AddRange(fileTestData);
                return(programmes.Count == featureTestData.Count && featureTestData.All(entity => programmes.Count(c => AreSameProgrammes(c, entity)) == 1));
            }

            case TestDataResultOperationType.Remove:
            case TestDataResultOperationType.Replace:
                return(true);

            default:
                return(false);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Creates recommendations data
        /// </summary>
        /// <param name="numberOfSpots">Number of spots to generate data for</param>
        /// <returns></returns>
        public List <Recommendation> Create(int numberOfSpots)
        {
            var recommendations = new List <Recommendation>();

            _random = new Random();
            DateTime processorDateTime = DateTime.UtcNow;

            // Load data
            var spots      = _spotRepository.GetAll();                                                     // Doesn't actually return all
            var salesAreas = _salesAreaRepository.GetAll();
            var programmes = _programmeRepository.GetAll();                                                // Doesn't actually return all

            numberOfSpots = (numberOfSpots > spots.ToList().Count ? spots.ToList().Count : numberOfSpots); // If insufficient spots then return max number

            if (!spots.Any())
            {
                throw new ArgumentException("Cannot generate fake recommendations data because there are no spots in the database");
            }
            if (!programmes.Any())
            {
                throw new ArgumentException("Cannot generate fake recommendations data because there are no programmes in the database");
            }

            // Add data for each spot
            int programmeIndex = -1;

            for (int spotIndex = 0; spotIndex < numberOfSpots; spotIndex++)
            {
                programmeIndex++;
                programmeIndex = (programmeIndex >= programmes.ToList().Count - 1 ? 0 : programmeIndex);
                var spot      = spots.ToList()[spotIndex];
                var salesArea = salesAreas.Where(x => x.Name.Equals(spot.SalesArea)).First();
                var programme = programmes.ToList()[++programmeIndex];

                recommendations.Add(CreateRecommendation(spots.ToList()[spotIndex], salesArea, programme, processorDateTime));
            }
            return(recommendations);
        }
 public List <Programme> GetAllProgrammeEvents()
 {
     return(_programmeRepository.GetAll().ToList());
 }
 public override IEnumerable <Programme> GetAll() => _repository.GetAll();