public ActionResult Index() { ReportsViewModel viewModel; // Get the default report var defaultReport = PowerBiHelper.FetchReport(_defaultsRepository.GetApplicationDefault(DefaultReportCode)); // Build up the view model if (defaultReport.Report != null) { viewModel = new ReportsViewModel() { SelectedReportId = new Guid(defaultReport.Report.Id), Reports = PowerBiHelper.FetchReports(defaultReport.Report.Id, "Seatingmap"), Report = defaultReport.Report, AccessToken = defaultReport.AccessToken }; } else { viewModel = new ReportsViewModel() { SelectedReportId = Guid.Empty, Reports = PowerBiHelper.FetchReports(null, "Seatingmap"), Report = null, AccessToken = string.Empty }; } return View(viewModel); }
public ActionResult Index(ReportsViewModel viewModel) { // Get the selected report var reportResult = PowerBiHelper.FetchReport(viewModel.SelectedReportId.ToString()); // Build up the view model viewModel.Reports = PowerBiHelper.FetchReports(viewModel.SelectedReportId.ToString()); viewModel.Report = reportResult.Report; viewModel.AccessToken = reportResult.AccessToken; return View(viewModel); }