Esempio n. 1
0
        public static Schedule Create(Conferences.Conference conference)
        {
            var res          = new Schedule(conference);
            var locations    = LocationRepository.Instance.GetLocationsByConference(conference.ConferenceId).OrderBy(l => l.Sort);
            var sessions     = SessionRepository.Instance.GetSessionsByConference(conference.ConferenceId).Where(s => s.Status > 2 && s.SlotId > 0 && s.DayNr > 0);
            var locationList = new List <Locations.Location>();

            foreach (var location in locations)
            {
                if (sessions.Where(s => s.LocationId == location.LocationId).Count() > 0)
                {
                    locationList.Add(location);
                }
            }
            res.Locations = locationList;
            var slots  = SlotRepository.Instance.GetSlotsByConference(conference.ConferenceId).OrderBy(s => s.StartMinutes);
            var nrDays = (conference.EndDate != null ? ((int)((DateTime)conference.EndDate).Subtract((DateTime)conference.StartDate).TotalDays) : 1);

            for (int dayNr = 0; dayNr < nrDays; dayNr++)
            {
                var ds         = new DaySchedule(((DateTime)conference.StartDate).AddDays(dayNr).Date, dayNr + 1);
                var nrSessions = 0;
                foreach (var slot in slots.Where(s => s.DayNr == dayNr + 1 | s.DayNr == null))
                {
                    var ts = new DaySchedule.TimeSlot(slot);
                    if (slot.SlotType == (int)SlotType.Session)
                    {
                        foreach (var session in sessions.Where(s => s.DayNr == dayNr + 1 & s.SlotId == slot.SlotId))
                        {
                            if (session.LocationId == null)
                            {
                                ts.Sessions.Add(-1, session);
                            }
                            else
                            {
                                ts.Sessions.Add((int)session.LocationId, session);
                            }
                            nrSessions++;
                        }
                    }
                    ds.Slots.Add(slot.StartMinutes, ts);
                }
                ds.TotalSessions = nrSessions;
                res.Days.Add(dayNr, ds);
            }
            return(res);
        }
Esempio n. 2
0
 public static Schedule Create(Conferences.Conference conference)
 {
     var res = new Schedule(conference);
     var locations = LocationRepository.Instance.GetLocations(conference.ConferenceId).OrderBy(l => l.Sort);
     var sessions = SessionRepository.Instance.GetSessions(conference.ConferenceId).Where(s => s.Status > 2 && s.SlotId > 0 && s.DayNr > 0);
     var locationList = new List<Locations.Location>();
     foreach (var location in locations)
     {
         if (sessions.Where(s => s.LocationId == location.LocationId).Count() > 0)
         {
             locationList.Add(location);
         }
     }
     res.Locations = locationList;
     var slots = SlotRepository.Instance.GetSlots(conference.ConferenceId).OrderBy(s => s.StartMinutes);
     var nrDays = (conference.EndDate != null ? ((int)((DateTime)conference.EndDate).Subtract((DateTime)conference.StartDate).TotalDays) : 1);
     for (int dayNr = 0; dayNr < nrDays; dayNr++)
     {
         var ds = new DaySchedule(((DateTime)conference.StartDate).AddDays(dayNr).Date, dayNr + 1);
         var nrSessions = 0;
         foreach (var slot in slots.Where(s => s.DayNr == dayNr + 1 | s.DayNr == null))
         {
             var ts = new DaySchedule.TimeSlot(slot);
             if (slot.SlotType == (int)SlotType.Session)
             {
                 foreach (var session in sessions.Where(s => s.DayNr == dayNr + 1 & s.SlotId == slot.SlotId))
                 {
                     if (session.LocationId == null)
                     {
                         ts.Sessions.Add(-1, session);
                     }
                     else
                     {
                         ts.Sessions.Add((int)session.LocationId, session);
                     }
                     nrSessions++;
                 }
             }
             ds.Slots.Add(slot.StartMinutes, ts);
         }
         ds.TotalSessions = nrSessions;
         res.Days.Add(dayNr, ds);
     }
     return res;
 }