Inheritance: CallNavigationViewModel
Ejemplo n.º 1
0
        public static ReportLaunchViewModel Create(IRepository repository, CallForProposal callForProposal, Report report, bool forExport = false)
        {
            Check.Require(repository != null, "Repository must be supplied");
            var viewModel = new ReportLaunchViewModel { CallForProposal = callForProposal, Report = report, ForExport = forExport};
            viewModel.AvailableQuestions = callForProposal.Questions.Select(a => a.Name).ToList();

            return GenerateGeneric(viewModel, report, callForProposal);
        }
Ejemplo n.º 2
0
        private static ReportLaunchViewModel GenerateGeneric(ReportLaunchViewModel viewModel, Report report, CallForProposal callForProposal)
        {
            //deal with the column names
            foreach (var reportColumn in report.ReportColumns)
            {
                if (reportColumn.IsProperty || viewModel.AvailableQuestions.Contains(reportColumn.Name))
                {
                    viewModel.ColumnNames.Add(Inflector.Titleize(Inflector.Humanize(Inflector.Underscore(reportColumn.Name))));
                }
            }

            var proposals = callForProposal.Proposals.AsQueryable();
            if (!report.ShowUnsubmitted)
            {
                proposals = proposals.Where(a => a.IsSubmitted);
            }
            //foreach (var proposal in callForProposal.Proposals.Where(a => a.IsSubmitted))
            foreach (var proposal in proposals)
            {
                var row = new List<string>();

                foreach (var reportColumn in report.ReportColumns)
                {
                    if (reportColumn.IsProperty || viewModel.AvailableQuestions.Contains(reportColumn.Name))
                    {
                        row.Add(ExtractValue(reportColumn, proposal, viewModel.ForExport));
                    }
                }

                viewModel.RowValues.Add(row.ToArray());
            }

            return viewModel;
        }