Example #1
0
        private void CalculateBreaksAvailsForUtcDate(
            string salesAreaName,
            ImmutableList <IProgrammeForBreakAvailCalculation> programmes,
            IReadOnlyList <ISpotForBreakAvailCalculation> spots,
            IReadOnlyList <Break> breaks,
            Schedule scheduleForUtcDate,
            IBreakRepository breakRepository,
            IScheduleRepository scheduleRepository)
        {
            var breakUpdateHandler = new BreakAvailabilityUpdateHandler(
                _logger,
                breakRepository,
                scheduleForUtcDate);

            new BreakAndOptimiserAvailabilityCalculator <Break>(_logger, breakUpdateHandler)
            .Calculate(
                salesAreaName,
                programmes,
                breaks,
                spots
                );

            if (scheduleForUtcDate is null || !breakUpdateHandler.ScheduleBreaksHaveChanges)
            {
                return;
            }

            scheduleRepository.Update(scheduleForUtcDate);
        }
Example #2
0
 public CompareController(IBreakRepository breakRepository, ISpotRepository spotRepository, IProgrammeRepository programmeRepository, ICampaignRepository campaignRepository, IProductRepository productRepository, IClashRepository clashRepository)
 {
     _breakrepo         = breakRepository;
     _spotrepo          = spotRepository;
     _programmerepo     = programmeRepository;
     _campaignrepo      = campaignRepository;
     _productRepository = productRepository;
     _clashRepository   = clashRepository;
 }
Example #3
0
 public BreakResultChecker(
     ITestDataImporter dataImporter,
     IBreakRepository breakRepository,
     IScheduleRepository scheduleRepository,
     ISpotRepository spotRepository) : base(dataImporter)
 {
     _breakRepository    = breakRepository;
     _scheduleRepository = scheduleRepository;
     _spotRepository     = spotRepository;
 }
Example #4
0
 public BulkBreakCreatedEventHandler(
     IBreakRepository breakRepository,
     IScheduleRepository scheduleRepository,
     ISalesAreaRepository salesAreaRepository,
     IMetadataRepository metadataRepository,
     IMapper mapper)
 {
     _breakRepository     = breakRepository;
     _scheduleRepository  = scheduleRepository;
     _salesAreaRepository = salesAreaRepository;
     _metadataRepository  = metadataRepository;
     _mapper = mapper;
 }
Example #5
0
 public BreaksController(IBreakRepository breakRepository, IMapper mapper,
                         IScheduleRepository scheduleRepository, ISpotRepository spotRepository,
                         IDataChangeValidator dataChangeValidator, IAuditEventRepository auditEventRepository,
                         ISalesAreaRepository salesAreaRepository,
                         IRecalculateBreakAvailabilityService recalculateBreakAvailabilityService)
 {
     _breakRepository      = breakRepository;
     _spotRepository       = spotRepository;
     _mapper               = mapper;
     _scheduleRepository   = scheduleRepository;
     _dataChangeValidator  = dataChangeValidator;
     _auditEventRepository = auditEventRepository;
     _salesAreaRepository  = salesAreaRepository;
     _recalculateBreakAvailabilityService = recalculateBreakAvailabilityService;
 }
Example #6
0
        /// <summary>
        /// These breaks have already been calculated. The schedule breaks for
        /// the following day need updating as they're in a different Schedule.
        /// </summary>
        /// <param name="salesAreaName"></param>
        /// <param name="date"></param>
        /// <param name="programmesSpanningMidnight"></param>
        /// <param name="breaksForUtcDate"></param>
        /// <param name="breakRepository"></param>
        /// <param name="scheduleRepository"></param>
        private void CopyUpdatedPostMidnightBreakAvails(
            string salesAreaName,
            DateTime date,
            IReadOnlyList <IProgrammeForBreakAvailCalculation> programmesSpanningMidnight,
            IReadOnlyList <Break> breaksForUtcDate,
            IBreakRepository breakRepository,
            IScheduleRepository scheduleRepository)
        {
            if (programmesSpanningMidnight.Count == 0)
            {
                return;
            }

            var scheduleForUtcDatePlusOne = GetScheduleForUtcDate(
                salesAreaName,
                date,
                scheduleRepository);

            if (scheduleForUtcDatePlusOne is null)
            {
                return;
            }

            var breakUpdateHandler = new BreakAvailabilityUpdateHandler(
                _logger,
                breakRepository,
                scheduleForUtcDatePlusOne);

            foreach (var programme in programmesSpanningMidnight)
            {
                var breaksAfterMidnight = breaksForUtcDate
                                          .Where(theBreak => programme.DateTimeIsInProgramme(theBreak.ScheduledDate));

                if (!breaksAfterMidnight.Any())
                {
                    continue;
                }

                foreach (var oneBreak in breaksAfterMidnight)
                {
                    breakUpdateHandler.UpdateAvailability(oneBreak);
                    breakUpdateHandler.UpdateOptimizerAvailability(oneBreak);
                    scheduleRepository.Update(scheduleForUtcDatePlusOne);
                }
            }
        }
Example #7
0
 public SpotsController(
     ISpotRepository repository,
     IBreakRepository breakRepository,
     IScheduleRepository scheduleRepository,
     IDataChangeValidator dataChangeValidator,
     IAuditEventRepository auditEventRepository,
     ISpotModelCreator spotModelCreator,
     IMapper mapper)
 {
     _repository           = repository;
     _mapper               = mapper;
     _breakRepository      = breakRepository;
     _scheduleRepository   = scheduleRepository;
     _dataChangeValidator  = dataChangeValidator;
     _auditEventRepository = auditEventRepository;
     _spotModelCreator     = spotModelCreator;
 }
 public BreakDomainModelHandler(IBreakRepository breakRepository) =>
Example #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="breakRepository"></param>
        /// <param name="minRestBetweenShifts">Minimum pause between shifts.</param>
        public PauseBetweenActions(IBreakRepository breakRepository)
        {
            BreakRepository = breakRepository ?? throw new ArgumentNullException(nameof(breakRepository), "IBreakRepository cannot be null.");

            _catchedLunches = new Dictionary <DateTime, Queue <Shift> > ();
        }
 public BreakAvailabilityUpdateHandler(ILogger logger, IBreakRepository breakRepository, Schedule schedule)
 {
     _logger            = logger ?? throw new ArgumentNullException(nameof(logger));
     _breakRepository   = breakRepository ?? throw new ArgumentNullException(nameof(breakRepository));
     _scheduleUtilities = CreateScheduleUtilities(schedule);
 }