示例#1
0
        private FIT_RESULT addToRoster(WeekRoster roster, Child currentChild, AttendanceRequest bringWish)
        {
            List<Child> children = roster.getChildren(bringWish.Dayparts);
            List<Caregiver> caregivers = roster.getCaregivers(bringWish.Dayparts);
            if (children.Count >= 13) // TODO: remove magic numbers
                return FIT_RESULT.FULL;
            if (children.Count + 1 - caregivers.Count * 5 > 0) // TODO: remove magic numbers
                return FIT_RESULT.INSUFFICIENT_CAREGIVERS;
            // TODO: max 3 babies

            roster.addChild(bringWish.Dayparts, currentChild);
            return FIT_RESULT.SUCCESS;
        }
示例#2
0
 private bool addCaregiver(WeekRoster roster, List<Caregiver> caregivers, AttendanceRequest bringWish)
 {
     List<Caregiver> rosteredCaregivers = roster.getCaregivers();            
     // first see if we can add a new parent before shifting            
     Caregiver availableCaregiver = getAvailableCaregiver(caregivers.Except(rosteredCaregivers).ToList(), bringWish);
     if (availableCaregiver != null)
     {
         roster.addCaregiver(bringWish.Dayparts, availableCaregiver);
         return true;
     }
     else
     {
         return shiftCaregiver(roster, caregivers, rosteredCaregivers, bringWish);
     }
 }
示例#3
0
        public WeekRoster getRoster(List<Caregiver> caregivers, List<Child> children)
        {
            WeekRoster roster = new WeekRoster();

            foreach(Child currentChild in children)
            {
                //There are many AttendanceRequest,.. todo select period that matters.
                //var period = currentChild.AttendanceRequest.FirstOrDefault();

                //foreach (DayPart daypart in period.Dayparts.ToParts())
                //AttendanceRequest bringWish = new AttendanceRequest(daypart);
                foreach (AttendanceRequest bringWish in currentChild.AttendanceRequest)
                {
                    
                    FIT_RESULT result = addToRoster(roster, currentChild, bringWish);
                    switch (result)
                    {
                        case FIT_RESULT.FULL:
                            if (shiftChild(roster, bringWish))
                                result = addToRoster(roster, currentChild, bringWish);
                            break; // TODO I don't want to break here, as there might not be sufficient parents now, but cannot reset result of course, maybe use stacked ifs instead of switch?
                        case FIT_RESULT.INSUFFICIENT_CAREGIVERS:
                            if (addCaregiver(roster, caregivers, bringWish))
                                result = addToRoster(roster, currentChild, bringWish);
                            break;
                        default:
                            break;
                    }
                    if (result != FIT_RESULT.SUCCESS)
                    {
                        // could not place child, error or report and go on and let human fix it?
                        Console.WriteLine("Failure: " + result + " for child " + currentChild);
                    }
                }
            }

            return roster;
        }
示例#4
0
 private bool shiftCaregiver(WeekRoster roster, List<Caregiver> parents, List<Caregiver> rosteredParents, AttendanceRequest bringWish)
 {
     // TODO: see if a parent can move to this day, put another on that day and move, return true on success
     // TODO: check if not exceeding max number with adding the parent's children
     return false;
 }
示例#5
0
 private bool shiftChild(WeekRoster roster, AttendanceRequest bringWish)
 {
     // TODO: see if a child can move away from this day, put it there, return true on success
     return false;
 }