public ScheduleEntity MapToScheduleEntity(ScheduleDataDTO source, ScheduleEntity target = null)
        {
            if (source == null)
            {
                return(null);
            }
            if (target == null)
            {
                GetScheduleEntity(source);
            }

            if (!MapToRevision(source, target))
            {
                return(target);
            }

            target.CreatedByUserId      = source.CreatedByUserId;
            target.LastModifiedByUserId = source.LastModifiedByUserId;
            target.Name = source.Name;
            MapCollection(source.Sessions, target.Sessions, (src, trg) =>
            {
                if (src is RaceSessionDataDTO raceSession)
                {
                    return(MapToRaceSessionEntity(raceSession, trg as RaceSessionEntity));
                }

                return(MapToSessionBaseEntity(src, trg));
            }, x => x.SessionId);

            return(target);
        }
        public ScheduleDataDTO MapToScheduleDataDTO(ScheduleEntity source, ScheduleDataDTO target = null)
        {
            if (source == null)
            {
                return(null);
            }
            if (target == null)
            {
                target = new ScheduleDataDTO();
            }

            MapToScheduleInfoDTO(source, target);
            target.CreatedByUserId      = source.CreatedByUserId;
            target.LastModifiedByUserId = source.LastModifiedByUserId;
            target.Name     = source.Name;
            target.Sessions = source.Sessions.Select(MapTo <SessionDataDTO>).ToList();

            return(target);
        }
        public IEnumerable <IEnumerable <IEnumerable <ScheduleDataDTO> > > MapScheduleToDTO(int [,] solution, int upperBound = 35 *5)
        {
            var scheduleData = new List <List <List <ScheduleDataDTO> > >();
            var week         = -1;

            for (int i = 0; i < 5; i++)
            {
                scheduleData.Add(new List <List <ScheduleDataDTO> >());
            }
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 7; j++)
                {
                    scheduleData[i].Add(new List <ScheduleDataDTO>());
                }
            }


            for (int i = 0; i < upperBound; i++)
            {
                int day       = (int)Math.Floor(i / 5.0) % 7;
                int shiftType = i % 5;
                if (i % 35 == 0)
                {
                    week++;
                }
                if (shiftType == 4)
                {
                    continue;
                }
                for (int j = 0; j < 16; j++)
                {
                    if (solution[j, i] == 1)
                    {
                        var obj = new ScheduleDataDTO();
                        obj.NurseId   = j;
                        obj.NurseName = NursesList[j];
                        switch (shiftType)
                        {
                        case 0:
                            obj.Shift = "EARLY";
                            break;

                        case 1:
                            obj.Shift = "DAY";
                            break;

                        case 2:
                            obj.Shift = "LATE";
                            break;

                        case 3:
                            obj.Shift = "NIGHT";
                            break;

                        default:
                            throw new ArgumentException(nameof(shiftType));
                        }
                        scheduleData[week][day].Add(obj);
                    }
                }
            }

            return(scheduleData);
        }