Пример #1
0
        public IEnumerable <Engineer> Select(SupportScheduleSpecification supportScheduleSpecification)
        {
            var scheduleDate      = supportScheduleSpecification.Date;
            var supportCandidates = _engineerRepository.List();

            if (supportScheduleSpecification.RequireDayOffBetweenDaysWithShifts)
            {
                supportCandidates = _dayOffFilter.Filter(supportCandidates, scheduleDate);
            }

            supportCandidates = _shiftAvailabilityReconciler.Reconcile(
                supportCandidates,
                scheduleDate,
                supportScheduleSpecification.RequireSingleShiftPerEngineerPerDay,
                supportScheduleSpecification.RequireTwoShiftsInTwoWeeks);

            return(supportCandidates.ToList());
        }
Пример #2
0
        public IActionResult Post([FromBody] SupportScheduleSpecification supportScheduleSpecification)
        {
            if (supportScheduleSpecification == null)
            {
                return(BadRequest());
            }

            DailySchedule value;

            try
            {
                value = _supportScheduler.Schedule(supportScheduleSpecification);
            }
            catch (UnableToMeetSpecificationSchedulingException ex)
            {
                return(StatusCode((int)HttpStatusCode.Conflict, new { ex.Message }));
            }
            catch (SchedulingException ex)
            {
                return(BadRequest(new { ex.Message }));
            }

            return(CreatedAtRoute("GetSupportSchedule", new { date = LocalDatePattern.Iso.Format(value.Date) }, value));
        }