public ViewResult EditProjectFundingSourceBudgetByCostTypeForProject(ProjectPrimaryKey projectPrimaryKey)
        {
            var project                  = projectPrimaryKey.EntityObject;
            var calendarYearRange        = project.CalculateCalendarYearRangeForBudgetsWithoutAccountingForExistingYears();
            var projectRelevantCostTypes =
                project.GetAllProjectRelevantCostTypesAsSimples(ProjectRelevantCostTypeGroup.Budgets);
            var viewModel = new EditProjectFundingSourceBudgetByCostTypeViewModel(project, calendarYearRange, projectRelevantCostTypes);

            return(ViewEditProjectFundingSourceBudgetByCostType(project, calendarYearRange, viewModel));
        }
        public EditProjectFundingSourceBudgetByCostTypeCreateWorkflowContainerViewData(FirmaSession currentFirmaSession,
                                                                                       ProjectFirmaModels.Models.Project project,
                                                                                       ProposalSectionsStatus proposalSectionsStatus,
                                                                                       EditProjectFundingSourceBudgetByCostTypeViewData.EditProjectFundingSourceBudgetByCostTypeViewDataForAngular viewDataForAngularClass,
                                                                                       EditProjectFundingSourceBudgetByCostTypeViewModel viewModelForPartial
                                                                                       ) : base(currentFirmaSession, project, ProjectCreateSection.Budget.ProjectCreateSectionDisplayName, proposalSectionsStatus)
        {
            RequestFundingSourceUrl = SitkaRoute <HelpController> .BuildUrlFromExpression(x => x.MissingFundingSource());

            ViewDataForPartial  = new EditProjectFundingSourceBudgetByCostTypeViewData(viewDataForAngularClass, ProjectFundingSourceBudgetViewEnum.Create);
            ViewModelForPartial = viewModelForPartial;
        }
Beispiel #3
0
        public PartialViewResult EditProjectFundingSourceBudgetByCostTypeForProject(ProjectPrimaryKey projectPrimaryKey)
        {
            var project                    = projectPrimaryKey.EntityObject;
            var calendarYearRange          = project.CalculateCalendarYearRangeForBudgetsWithoutAccountingForExistingYears();
            var costTypes                  = HttpRequestStorage.DatabaseEntities.CostTypes.ToList();
            var projectRelevantCostTypes   = project.GetBudgetsRelevantCostTypes().Select(x => new ProjectRelevantCostTypeSimple(x)).ToList();
            var currentRelevantCostTypeIDs = projectRelevantCostTypes.Select(x => x.CostTypeID).ToList();

            projectRelevantCostTypes.AddRange(
                costTypes.Where(x => !currentRelevantCostTypeIDs.Contains(x.CostTypeID))
                .Select((x, index) => new ProjectRelevantCostTypeSimple(-(index + 1), project.ProjectID, x.CostTypeID, x.CostTypeName)));
            var viewModel = new EditProjectFundingSourceBudgetByCostTypeViewModel(project, calendarYearRange, projectRelevantCostTypes);

            return(ViewEditProjectFundingSourceBudgetByCostType(project, calendarYearRange, viewModel));
        }
        public EditProjectFundingSourceBudgetByCostTypeUpdateWorkflowContainerViewData(FirmaSession currentFirmaSession,
                                                                                       ProjectUpdateBatch projectUpdateBatch,
                                                                                       EditProjectFundingSourceBudgetByCostTypeViewData.EditProjectFundingSourceBudgetByCostTypeViewDataForAngular viewDataForAngularClass,
                                                                                       ProjectBudgetSummaryViewData projectBudgetSummaryViewData,
                                                                                       ProjectBudgetsAnnualByCostTypeViewData projectBudgetsAnnualByCostTypeViewData,
                                                                                       ProjectUpdateStatus projectUpdateStatus,
                                                                                       EditProjectFundingSourceBudgetByCostTypeValidationResult editProjectFundingSourceBudgetByCostTypeValidationResult,
                                                                                       EditProjectFundingSourceBudgetByCostTypeViewModel viewModelForPartial
                                                                                       ) : base(currentFirmaSession, projectUpdateBatch, projectUpdateStatus, editProjectFundingSourceBudgetByCostTypeValidationResult.GetWarningMessages(), ProjectUpdateSection.Budget.ProjectUpdateSectionDisplayName)
        {
            ProjectBudgetSummaryViewData           = projectBudgetSummaryViewData;
            ProjectBudgetsAnnualByCostTypeViewData = projectBudgetsAnnualByCostTypeViewData;


            bool showApproveAndReturnButton =
                ProjectFundingSourceByCostTypeViewDataHelper.ShowApproveAndReturnButtonForUpdateWorkflow(projectUpdateBatch,
                                                                                                         currentFirmaSession);

            ViewDataForPartial  = new EditProjectFundingSourceBudgetByCostTypeViewData(viewDataForAngularClass, ProjectFundingSourceBudgetViewEnum.Update, projectUpdateBatch, projectUpdateStatus.IsBudgetsUpdated, showApproveAndReturnButton);
            ViewModelForPartial = viewModelForPartial;
        }
        private ViewResult ViewEditProjectFundingSourceBudgetByCostType(Project project, List <int> calendarYearRange, EditProjectFundingSourceBudgetByCostTypeViewModel viewModel)
        {
            var allFundingSources        = HttpRequestStorage.DatabaseEntities.FundingSources.ToList().Select(x => new FundingSourceSimple(x)).OrderBy(p => p.DisplayName).ToList();
            var allCostTypes             = HttpRequestStorage.DatabaseEntities.CostTypes.ToList().Select(x => new CostTypeSimple(x)).OrderBy(p => p.CostTypeName).ToList();
            var fundingTypes             = FundingType.All.ToList().ToSelectList(x => x.FundingTypeID.ToString(CultureInfo.InvariantCulture), y => y.FundingTypeDisplayName);
            var viewDataForAngularEditor = new EditProjectFundingSourceBudgetByCostTypeViewData.EditProjectFundingSourceBudgetByCostTypeViewDataForAngular(project, allFundingSources, allCostTypes, calendarYearRange, fundingTypes);

            var containerViewData = new EditProjectFundingSourceBudgetByCostTypeContainerViewData(CurrentFirmaSession, project, viewDataForAngularEditor, viewModel);

            return(RazorView <EditProjectFundingSourceBudgetByCostTypeContainer, EditProjectFundingSourceBudgetByCostTypeContainerViewData>(containerViewData));
        }
        public ActionResult EditProjectFundingSourceBudgetByCostTypeForProject(ProjectPrimaryKey projectPrimaryKey, EditProjectFundingSourceBudgetByCostTypeViewModel viewModel)
        {
            var project = projectPrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                var calendarYearRange = project.CalculateCalendarYearRangeForBudgetsWithoutAccountingForExistingYears();
                return(ViewEditProjectFundingSourceBudgetByCostType(project, calendarYearRange, viewModel));
            }
            // if user pressed save button, save their changes before returning them to the project detail page
            if (viewModel.ShouldSaveChanges)
            {
                viewModel.UpdateModel(project, HttpRequestStorage.DatabaseEntities);
                SetMessageForDisplay($"Projected Funding updated for {project.ProjectName}.");
            }

            return(Redirect(project.GetDetailUrl() + "#financials-1"));
        }
        /// <summary>
        /// Method to check whether each section in a proposal is complete
        ///
        /// </summary>
        /// <param name="project"></param>
        /// <param name="geospatialAreaTypes">Geospatial areas are defined per tenant, this is passed to check if the tenant has any and are complete</param>
        public ProposalSectionsStatus(ProjectFirmaModels.Models.Project project, List <GeospatialAreaType> geospatialAreaTypes, FirmaSession currentFirmaSession)
        {
            // Basics section
            var basicsResults = new BasicsViewModel(project).GetValidationResults();

            IsBasicsSectionComplete = !basicsResults.Any();

            // Custom Attributes section
            var customAttributesValidationResults = project.ValidateCustomAttributes(currentFirmaSession).GetWarningMessages();

            IsProjectCustomAttributesSectionComplete = !customAttributesValidationResults.Any();

            // Project Location simple section
            var locationSimpleValidationResults = new LocationSimpleViewModel(project).GetValidationResults();

            IsProjectLocationSimpleSectionComplete = !locationSimpleValidationResults.Any();

            // Project location detailed section
            IsProjectLocationDetailedSectionComplete = IsBasicsSectionComplete;

            // Geospatial Area section
            if (geospatialAreaTypes.Any())
            {
                var isGeospatialAreaSectionComplete = true;
                foreach (var geospatialAreaType in geospatialAreaTypes)
                {
                    var geospatialAreaIDs = project.ProjectGeospatialAreas.Where(x => x.GeospatialArea.GeospatialAreaTypeID == geospatialAreaType.GeospatialAreaTypeID).Select(x => x.GeospatialAreaID).ToList();
                    var editGeospatialAreaValidationResults = new EditProjectGeospatialAreasViewModel(geospatialAreaIDs, project.ProjectGeospatialAreaTypeNotes.SingleOrDefault(x => x.GeospatialAreaTypeID == geospatialAreaType.GeospatialAreaTypeID)?.Notes).GetValidationResults();
                    if (editGeospatialAreaValidationResults.Any())
                    {
                        isGeospatialAreaSectionComplete = false;
                        break;
                    }
                }

                IsGeospatialAreaSectionComplete = isGeospatialAreaSectionComplete;
            }
            else
            {
                IsGeospatialAreaSectionComplete = true;
            }

            // Performance Measure section
            IsPerformanceMeasureSectionComplete = IsBasicsSectionComplete;

            // Project FundingSource Budget and Cost Type section
            var calendarYearRange = project.CalculateCalendarYearRangeForBudgetsWithoutAccountingForExistingYears();
            var allProjectRelevantCostTypesAsSimples = project.GetAllProjectRelevantCostTypesAsSimples(ProjectRelevantCostTypeGroup.Budgets);
            var budgetValidationResults =
                new EditProjectFundingSourceBudgetByCostTypeViewModel(project, calendarYearRange,
                                                                      allProjectRelevantCostTypesAsSimples).GetValidationResults();

            IsExpectedFundingSectionComplete = !budgetValidationResults.Any();

            // Classifications section
            var proposalClassificationSimples   = ProjectCreateController.GetProjectClassificationSimples(project);
            var classificationValidationResults = new EditProposalClassificationsViewModel(proposalClassificationSimples, project).GetValidationResults();

            IsClassificationsComplete = !classificationValidationResults.Any();

            // Assessment section
            IsAssessmentComplete = ProjectCreateController.GetProjectAssessmentQuestionSimples(project).All(simple => simple.Answer.HasValue);

            // Notes section
            IsNotesSectionComplete = IsBasicsSectionComplete; //there is no validation required on Notes
        }
Beispiel #8
0
        private PartialViewResult ViewEditProjectFundingSourceBudgetByCostType(Project project, List <int> calendarYearRange, EditProjectFundingSourceBudgetByCostTypeViewModel viewModel)
        {
            var allFundingSources        = HttpRequestStorage.DatabaseEntities.FundingSources.ToList().Select(x => new FundingSourceSimple(x)).OrderBy(p => p.DisplayName).ToList();
            var allCostTypes             = HttpRequestStorage.DatabaseEntities.CostTypes.ToList().Select(x => new CostTypeSimple(x)).OrderBy(p => p.CostTypeName).ToList();
            var fundingTypes             = FundingType.All.ToList().ToSelectList(x => x.FundingTypeID.ToString(CultureInfo.InvariantCulture), y => y.FundingTypeDisplayName);
            var viewDataForAngularEditor = new EditProjectFundingSourceBudgetByCostTypeViewData.ViewDataForAngularClass(project, allFundingSources, allCostTypes, calendarYearRange, fundingTypes);
            var viewData = new EditProjectFundingSourceBudgetByCostTypeViewData(viewDataForAngularEditor);

            return(RazorPartialView <EditProjectFundingSourceBudgetByCostType, EditProjectFundingSourceBudgetByCostTypeViewData, EditProjectFundingSourceBudgetByCostTypeViewModel>(viewData, viewModel));
        }
Beispiel #9
0
        public ActionResult EditProjectFundingSourceBudgetByCostTypeForProject(ProjectPrimaryKey projectPrimaryKey, EditProjectFundingSourceBudgetByCostTypeViewModel viewModel)
        {
            var project           = projectPrimaryKey.EntityObject;
            var calendarYearRange = project.CalculateCalendarYearRangeForBudgetsWithoutAccountingForExistingYears();

            if (!ModelState.IsValid)
            {
                return(ViewEditProjectFundingSourceBudgetByCostType(project, calendarYearRange, viewModel));
            }
            viewModel.UpdateModel(project, HttpRequestStorage.DatabaseEntities);
            return(new ModalDialogFormJsonResult());
        }