public SessionInfoViewModel (IRepository repository, Session session, Slot slot )
        {
            Session = session;
            Title = session.Title;
            Location = session.Location;
//            Track = session.Track;
            Time = slot.StartTime;
			Abstract = session.Abstract;

			Track = session == null ? "None" :
				!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";

			var speakerId = session.SpeakerIds.FirstOrDefault ();
			if (String.IsNullOrWhiteSpace (speakerId) == false)
			{
				Speaker speaker = repository.GetSpeaker (speakerId);
				if (speaker != null)
				{
					PrimarySpeakerName = String.Format ("{0} {1}", speaker.First, speaker.Last);
					PrimarySpeakerCompany = speaker.Company;
					PrimarySpeakerRole = speaker.Role;
					PrimarySpeakerHeadshot = speaker.HeadshotUrl;
				}
			}
		}
		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 ChooseSessionView (Slot slot, Session session)
		{
            BaseViewModel.CreateAndBind<ChooseSessionViewModel> (this, slot, session);

			NavigationPage.SetBackButtonTitle (this, "");

            ToolbarItems.Add (CreateSelectButton ());

            SetBinding (ChooseSessionView.NavigationProperty, new Binding ("Navigation"));
            SetBinding (ChooseSessionView.TitleProperty, new Binding ("Title"));
            SetBinding (ChooseSessionView.SelectButtonTextProperty, new Binding ("SelectButtonText"));

			var relativeLayout = new RelativeLayout 
			{
				HorizontalOptions = LayoutOptions.FillAndExpand,
				VerticalOptions = LayoutOptions.FillAndExpand
			};

			var lowerStackLayout = new StackLayout 
			{
				HorizontalOptions = LayoutOptions.CenterAndExpand,
				VerticalOptions = LayoutOptions.EndAndExpand,
				Spacing = 20,
				Padding = new Thickness (0, 20, 0, 20),
			};
			lowerStackLayout.Children.Add (CreatePips ());
			lowerStackLayout.Children.Add (CreateRateButton ());

			relativeLayout.Children.Add (lowerStackLayout,
				Constraint.RelativeToParent ((parent) => { return parent.X; }),
				Constraint.RelativeToParent ((parent) => { return parent.Height - 100; }),
				Constraint.RelativeToParent ((parent) => { return parent.Width; })
			);

			sessionInfoCarousel = CreateSessionInfoCarousel ();
			relativeLayout.Children.Add (sessionInfoCarousel,
				Constraint.RelativeToParent ((parent) => { return parent.X; }),
				Constraint.RelativeToParent ((parent) => { return parent.Y; }),
				Constraint.RelativeToParent ((parent) => { return parent.Width; }),
				Constraint.RelativeToView (lowerStackLayout, (parent,sibling) => { return parent.Height - sibling.Height; })
			);

			var fadeOut = CreateFadeOut ();
			relativeLayout.Children.Add (fadeOut,
				Constraint.RelativeToParent (parent => { return parent.X; }),
				Constraint.RelativeToView (lowerStackLayout, (parent,sibling) => { return sibling.Y - 30; }),
				Constraint.RelativeToParent (parent => { return parent.Width; }),
				Constraint.Constant (40)
			);

			Content = relativeLayout;
		}
        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 void SetUp ()
        {
            _sessionIds = new List<string> ();

            _slot1 = new Slot {
                StartTime = new DateTime (2014, 10, 1, 8, 0, 0),
                EndTime = new DateTime (2014, 10, 1, 8, 50, 0),
                SessionIds = _sessionIds
            };

            _slot2 = new Slot {
                StartTime = new DateTime (2014, 10, 1, 9, 0, 0),
                EndTime = new DateTime (2014, 10, 1, 9, 50, 0),
                SessionIds = _sessionIds
            };

            _days = new List<Day> {
                new Day {
                    Date = new DateTime(2014, 10, 1),
                    Slots = new List<Slot> {
                        _slot1,
                        _slot2
                    }
                }
            };

            _schedule = new Schedule { Days = _days };
            _appConfig = new AppConfig ();

            _repository = new MockRepository {
                GetDaysResult = _days,
                GetScheduleResult = _schedule,
                GetAppConfigResult = _appConfig
            };

            _sessions = new List<Session> ();
            _repository.GetSessionsResults [_sessionIds] = _sessions;

            _timeService = new MockTimeService ();
            _twitterService = new MockTwitterService ();
            _sut = new HomeViewModel (_repository, _timeService, _twitterService);
        }
        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 AgendaCellViewModel (Slot slot)
 {
     Slot = slot;
     Time = slot.StartTime;
 }
 public void should_get_current_sessions_from_current_slot () {
     var slot = new Slot { SessionIds = _sessionIds };
     _sut.CurrentSlot = slot;
     Assert.AreSame (_sessions, _sut.CurrentSessions);
 }
		public HomeCurrentSessionViewModel (Slot slot, Session session)
		{
			Session = session;
			CurrentSlot = slot;
		}