protected ProjectCreateViewData(FirmaSession currentFirmaSession, ProjectFirmaModels.Models.Project project, string currentSectionDisplayName, ProposalSectionsStatus proposalSectionsStatus) : this(currentFirmaSession, project, currentSectionDisplayName, false) { Check.Assert(project != null, "Project should be created in database by this point so it cannot be null."); Check.Assert(currentSectionDisplayName.Equals("Instructions", StringComparison.InvariantCultureIgnoreCase) || currentSectionDisplayName.Equals("Basics", StringComparison.InvariantCultureIgnoreCase) || proposalSectionsStatus.IsBasicsSectionComplete, $"Can't access this section of the Proposal - You must complete the basics first ({project.GetEditUrl()})"); CurrentPersonCanWithdraw = new ProjectCreateFeature().HasPermission(currentFirmaSession, project).HasPermission; Project = project; ProposalSectionsStatus = proposalSectionsStatus; CanAdvanceStage = ProposalSectionsStatus.AreAllSectionsValidForProject(project, CurrentFirmaSession); // ReSharper disable PossibleNullReferenceException ProjectStateIsValidInWizard = project.ProjectApprovalStatus == ProjectApprovalStatus.Draft || project.ProjectApprovalStatus == ProjectApprovalStatus.Returned || project.ProjectApprovalStatus == ProjectApprovalStatus.PendingApproval; // ReSharper restore PossibleNullReferenceException IsInstructionsPage = currentSectionDisplayName.Equals("Instructions", StringComparison.InvariantCultureIgnoreCase); InstructionsPageUrl = project.ProjectStage == ProjectStage.Proposal ? SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.InstructionsProposal(project.ProjectID)) : SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.InstructionsEnterHistoric(project.ProjectID)); var fieldDefinitionLabelForProject = FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel(); var pageTitle = project.ProjectStage == ProjectStage.Proposal ? $"Propose {fieldDefinitionLabelForProject}" : $"Add {fieldDefinitionLabelForProject}"; PageTitle = $"{pageTitle}: {project.GetDisplayName()}"; ProposalDetailUrl = SitkaRoute <ProjectController> .BuildUrlFromExpression(x => x.Detail(project)); ProposalBasicsUrl = SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.EditBasics(project.ProjectID)); ProposalAttachmentsAndNotesUrl = SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.AttachmentsAndNotes(project.ProjectID)); ProposalPhotosUrl = SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.Photos(project.ProjectID)); SubmitUrl = SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.Submit(project)); ApproveUrl = SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.Approve(project)); ReturnUrl = SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.Return(project)); WithdrawUrl = SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.Withdraw(project)); RejectUrl = SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.Reject(project)); TrainingUrl = SitkaRoute <HomeController> .BuildUrlFromExpression(x => x.Training()); ProjectStage = project.ProjectStage; HasCustomAttributesEditableByUser = project.HasEditableCustomAttributes(currentFirmaSession); }
public static bool AreAllSectionsValidForProject(ProjectFirmaModels.Models.Project project, FirmaSession currentFirmaSession) { return(project.GetApplicableProposalWizardSections(false, project.HasEditableCustomAttributes(currentFirmaSession)).All(x => x.IsComplete)); }