public FullScheduleCellViewModel ( IRepository repository, Session session, Agenda agenda, Slot slot, IEnumerable<string> trackFilters ) { this._repository = repository; this._slot = slot; this._agenda = agenda; Session = session; Title = session.Title; Location = session.Location; // Track = session.Track; IsOptional = slot.SessionIds.Skip(1).Any(); IsSelected = IsOptional && agenda.IsSelected (slot.StartTime, session.Id); Track = !string.IsNullOrEmpty (session.Track) ? session.Track : string.IsNullOrEmpty (session.Title) ? "None" : // check title for registration session.Title == "Registration" ? session.Title : // check title for any breaks session.Title == "Break" || session.Title == "Breakfast" || session.Title == "Lunch" || session.Title == "Afternoon Break" || session.Title == "Party" ? "MealBreak" : "NoTrack"; }
public FullScheduleDayViewModel (IRepository repository, Day day, Agenda agenda, IEnumerable<string> trackFilters) { this._trackFilters = trackFilters; this._repository = repository; Date = day.Date; Slots = day.Slots .Select (slot => CreateFullScheduleSessionGroup (slot, agenda)).ToList (); }
public void should_select_first_day () { var agenda = new Agenda (); var trackFilters = new List<string> (); _sut.FullScheduleDays = new List<FullScheduleDayViewModel> { new FullScheduleDayViewModel (_repository, new Day (), agenda, trackFilters), new FullScheduleDayViewModel (_repository, new Day (), agenda, trackFilters) }; Assert.AreSame (_sut.FullScheduleDays.First (), _sut.SelectedDay); }
FullScheduleSessionGroup CreateFullScheduleSessionGroup (Slot slot, Agenda agenda) { var group = new FullScheduleSessionGroup (slot); group.StartTime = slot.StartTime; var sessions = slot.SessionIds.Select (sessionId => _repository.GetSession (sessionId)); if (_trackFilters.Any ()) sessions = sessions.Where (session => IsInFilter (session)); group.AddRange (sessions.Select (session => new FullScheduleCellViewModel ( _repository, session, agenda, slot, _trackFilters))); return group; }
public IEnumerable<AgendaDayViewModel> CreateAgendaDays (IEnumerable<Day> days, Agenda agenda) { var sessionIds = days .SelectMany (day => day.Slots) .SelectMany (slot => slot.SessionIds) .ToList (); var sessions = _repository.GetSessions (sessionIds).Result; var agendaDays = days.Select (day => new AgendaDayViewModel { Date = day.Date, Slots = day.Slots.Select(slot => new { Slot = slot, Session = SessionForSlot (slot, agenda, sessions) }) .Select (slotSession => new AgendaCellViewModel (slotSession.Slot) { Title = slotSession.Session != null ? slotSession.Session.Title : "None", Location = slotSession.Session != null ? slotSession.Session.Location : "None", Time = slotSession.Slot.StartTime, IsBooked = slotSession.Session != null, Track = slotSession.Session == null ? "None" : !string.IsNullOrEmpty(slotSession.Session.Track) ? slotSession.Session.Track : string.IsNullOrEmpty(slotSession.Session.Title) ? "None" : // check title for registration slotSession.Session.Title == "Registration" ? slotSession.Session.Title : // check title for any breaks slotSession.Session.Title == "Break" || slotSession.Session.Title == "Breakfast" || slotSession.Session.Title == "Lunch" || slotSession.Session.Title == "Afternoon Break" || slotSession.Session.Title == "Party" ? "MealBreak" : "NoTrack" }) }); return agendaDays; }
static Session SessionForSlot (Slot slot, Agenda agenda, IEnumerable<Session> sessions) { //Console.WriteLine ("Slot: " + slot.StartTime + " Agenda: " + agenda.Id); return !slot.SessionIds.Skip (1).Any () ? sessions.Single (session => session.Id == slot.SessionIds.First ()) : sessions.FirstOrDefault (session => agenda.IsSelected (slot.StartTime, session.Id)); }
public void should_get_agenda_from_repo_on_initialize() { _repository.GetDaysResult = new List<Day> (); var agenda = new Agenda(); _repository.GetAgendaResult = agenda; _sut.Initialize ().Wait (); Assert.AreSame (agenda, _sut.Agenda); }
public void should_add_session_to_agenda_when_no_other_options_in_slot() { var days = new List<Day> { new Day { Date = new DateTime (2014, 10, 9), Slots = new List<Slot> { new Slot { StartTime = new DateTime (2014, 10, 9, 9, 15, 0), SessionIds = new List<string> () { "1" } // new Session { // Id = "1", // Title = "Session One", // Location = "Location One" } } } }; var agenda = new Agenda { // Sessions = {} }; var agendaDays = _sut.CreateAgendaDays (days, agenda); Assert.AreEqual (days.Count, agendaDays.Count()); Assert.AreEqual (days.First ().Slots.Count(), agendaDays.First ().Slots.Count()); Assert.AreEqual (days.First ().Slots.First ().SessionIds.First (), agendaDays.First ().Slots.First ()); }
public void should_create_agenda_days_from_days_and_agenda() { var days = new List<Day> { new Day { Date = new DateTime(2014, 10, 9), Slots = new List<Slot> { new Slot { StartTime = new DateTime(2014, 10, 9, 9, 15, 0), SessionIds = new List<string>{ "1", "2"} // { // new Session { // Id = "1", // Title = "Session One", // Location = "Location One" // }, // new Session { // Id = "2", // Title = "Session Two", // Location = "Location Two" // } // } } } } }; var agenda = new Agenda { // Sessions = new List<UserSession> { // new UserSession { // SlotId = "2", // SessionId = "1" // } // } }; var agendaDays = _sut.CreateAgendaDays (days, agenda); Assert.AreEqual (days.Count, agendaDays.Count()); Assert.AreEqual (days.First ().Slots.Count(), agendaDays.First ().Slots.Count()); Assert.AreEqual (days.First ().Slots.First ().SessionIds.First (), agendaDays.First ().Slots.First ()); }
public void SaveAgenda (Agenda agenda) { throw new NotImplementedException (); }