public async Task <IActionResult> Index() { IWho who = this.Who(); this.logger.ReportEntry(who); IList <IMeeting> meetings = await this.service .GetRecentMeetingsMostRecentFirstAsync(who) .ConfigureAwait(false); ISetupStatus setupStatus = meetings.Any() ? new SetupStatus(haveOrganisations: true, haveCommittees: true) : await this.service .GetSetupStatusAsync(who) .ConfigureAwait(false); bool featureEnabled = await this.featureManager .IsEnabledAsync(nameof(FeatureFlag.NewReferenceSearch)) .ConfigureAwait(false); IndexViewModel model = IndexViewModel.Create(meetings, setupStatus, featureEnabled); ViewResult view = this.View(model); this.logger.ReportExitView( who, view.ViewName, view.Model, view.StatusCode); return(view); }
/// <summary> /// Creates this instance. /// </summary> /// <param name="recentMeetings">Recent meetings.</param> /// <param name="setupStatus">Setup status.</param> /// <param name="featureEnabled">Is Feature Enabled.</param> /// <returns>Index view model.</returns> public static IndexViewModel Create( IList<IMeeting> recentMeetings, ISetupStatus setupStatus, bool featureEnabled) { return new IndexViewModel( noRecentMeetingsViewModel: NoRecentMeetingsViewModel.Create(setupStatus), meetingCardViewModels: recentMeetings .Select(MeetingCardViewModel.Create) .ToList(), featureEnabled: featureEnabled); }
/// <summary> /// Creates a No Recent Meetings view model. /// </summary> /// <param name="setupStatus">The setup status.</param> /// <returns>No Recent Meetings view model.</returns> public static NoRecentMeetingsViewModel Create(ISetupStatus setupStatus) { if (setupStatus == null) { return(new NoRecentMeetingsViewModel( showAddOrganisationButton: false, showAddCommitteeButton: false, showAddMeetingButton: false)); } return(new NoRecentMeetingsViewModel( showAddOrganisationButton: !setupStatus.HaveOrganisations, showAddCommitteeButton: setupStatus.HaveOrganisations && !setupStatus.HaveCommittees, showAddMeetingButton: setupStatus.HaveOrganisations && setupStatus.HaveCommittees)); }
private static Mock <IAgendaService> CreateAgendaServiceMock( IList <IMeeting> meetingList, ISetupStatus setupStatus) { Mock <IAgendaService> serviceMock = new Mock <IAgendaService>(MockBehavior.Strict); serviceMock.Setup(x => x.GetRecentMeetingsMostRecentFirstAsync( It.IsAny <IWho>(), It.IsAny <TimeSpan?>(), It.IsAny <int?>())) .ReturnsAsync(meetingList); serviceMock.Setup(x => x.GetSetupStatusAsync( It.IsAny <IWho>())) .ReturnsAsync(setupStatus); return(serviceMock); }