예제 #1
0
        public void UpdateModelAndSaveChanges(ProjectFirmaModels.Models.Agreement agreement,
                                              FirmaSession currentFirmaSession,
                                              DatabaseEntities databaseEntities)
        {
            agreement.AgreementNumber = this.AgreementNumber.ToUpper();
            agreement.OrganizationID  = this.OrganizationID;
            agreement.ContractTypeID  = this.ContractTypeID.Value;

            if (agreement.AgreementID <= 0)
            {
                // We need to save the Agreement in order to get it's primary key before it can be associated
                // with an ObligationNumber
                HttpRequestStorage.DatabaseEntities.Agreements.Add(agreement);
                HttpRequestStorage.DatabaseEntities.SaveChanges();
            }
            Check.Ensure(agreement.AgreementID > 0, "Was expecting valid primary key by now");

            // Is Obligation already set in the Agreement?
            var  currentObligationNumber    = agreement.ObligationNumbersWhereYouAreTheReclamationAgreement.SingleOrDefault();
            bool currentObligationNumberSet = currentObligationNumber != null;

            // Did the user set an Obligation number in their form POST?
            bool obligationWasSetInFormPost = this.ObligationNumberID.HasValue;

            // Do we need to clear the current Obligation?
            bool needToClearCurrentObligationNumber = currentObligationNumberSet;

            // Do we need to set the Obligation?
            bool needToSetObligation = obligationWasSetInFormPost;

            // Special case: User is setting Obligation to what it is already set to.
            if (obligationWasSetInFormPost && currentObligationNumberSet)
            {
                // Is the Agreement already wired to this Obligation?
                if (currentObligationNumber.ObligationNumberID == this.ObligationNumberID.Value)
                {
                    // Nothing to do
                    needToSetObligation = false;
                    needToClearCurrentObligationNumber = false;
                }
            }

            if (needToClearCurrentObligationNumber)
            {
                currentObligationNumber.ReclamationAgreement   = null;
                currentObligationNumber.ReclamationAgreementID = null;
            }

            if (needToSetObligation)
            {
                var obligationNumber = databaseEntities.ObligationNumbers.Single(oNum => oNum.ObligationNumberID == this.ObligationNumberID.Value);
                obligationNumber.ReclamationAgreementID = agreement.AgreementID;
            }

            // Save changes to ObligationNumber
            HttpRequestStorage.DatabaseEntities.SaveChanges();
        }
예제 #2
0
        public AgreementEditViewModel(ProjectFirmaModels.Models.Agreement agreement)
        {
            AgreementNumber = agreement.AgreementNumber;
            OrganizationID  = agreement.OrganizationID;
            ContractTypeID  = agreement.ContractTypeID;
            var associatedObligationNumber = agreement.ObligationNumbersWhereYouAreTheReclamationAgreement.SingleOrDefault();

            ObligationNumberID = associatedObligationNumber?.ObligationNumberID;
        }
예제 #3
0
        public AgreementDetailViewData(FirmaSession currentFirmaSession, ProjectFirmaModels.Models.Agreement agreement) : base(currentFirmaSession)
        {
            PageTitle  = $"Agreement Number: {agreement.AgreementNumber}";
            EntityName = "Agreement Detail";

            Agreement = agreement;
            UserHasAgreementManagePermissions = new AgreementManageFeature().HasPermissionByPerson(CurrentPerson);
            IsAdmin = new FirmaAdminFeature().HasPermissionByPerson(CurrentPerson);

            EditAgreementBasicsUrl = SitkaRoute <AgreementController> .BuildUrlFromExpression(c => c.EditBasics(agreement));

            /*
             * EditPerformanceMeasureUrl = SitkaRoute<PerformanceMeasureController>.BuildUrlFromExpression(c => c.Edit(performanceMeasure));
             * EditSubcategoriesAndOptionsUrl = SitkaRoute<PerformanceMeasureController>.BuildUrlFromExpression(c => c.EditSubcategoriesAndOptions(performanceMeasure));
             *
             * EditCriticalDefinitionsUrl = SitkaRoute<PerformanceMeasureController>.BuildUrlFromExpression(c => c.EditPerformanceMeasureRichText(performanceMeasure, EditRtfContent.PerformanceMeasureRichTextType.CriticalDefinitions));
             * EditProjectReportingUrl = SitkaRoute<PerformanceMeasureController>.BuildUrlFromExpression(c => c.EditPerformanceMeasureRichText(performanceMeasure, EditRtfContent.PerformanceMeasureRichTextType.ProjectReporting));
             */

            IndexUrl = SitkaRoute <AgreementController> .BuildUrlFromExpression(c => c.AgreementIndex());

            CostAuthorityIndexUrl = SitkaRoute <CostAuthorityController> .BuildUrlFromExpression(cac => cac.CostAuthorityIndex());

            FieldDefinitionForAgreement = FieldDefinitionEnum.Agreement.ToType();
            FieldDefinitionForProject   = FieldDefinitionEnum.Project.ToType();
            FieldDefinitionForCostAuthorityWorkBreakdownStructure = FieldDefinitionEnum.CostAuthorityWorkBreakdownStructure.ToType();


            /* Basic Project Info */
            BasicProjectInfoProjectGridName = "agreementProjectListGrid";
            BasicProjectInfoGridSpec        = new BasicProjectInfoGridSpec(currentFirmaSession, true, agreement)
            {
                ObjectNameSingular  = $"{FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} associated with Agreement Number {agreement.AgreementNumber}",
                ObjectNamePlural    = $"{FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabelPluralized()} associated with Agreement Number {agreement.AgreementNumber}",
                SaveFiltersInCookie = true
            };
            BasicProjectInfoProjectGridDataUrl = SitkaRoute <AgreementController> .BuildUrlFromExpression(tc => tc.AgreementProjectsGridJsonData(agreement));

            /* Cost Authority */
            BasicCostAuthorityGridName = "costAuthorityAgreementListGrid";
            BasicCostAuthorityGridSpec = new BasicCostAuthorityGridSpec(CurrentPerson)
            {
                ObjectNameSingular  = $"{FieldDefinitionEnum.CostAuthorityWorkBreakdownStructure.ToType().GetFieldDefinitionLabel()} associated with {FieldDefinitionEnum.Agreement.ToType().GetFieldDefinitionLabel()} {agreement.AgreementNumber}",
                ObjectNamePlural    = $"{FieldDefinitionEnum.CostAuthorityWorkBreakdownStructure.ToType().GetFieldDefinitionLabelPluralized()} associated with {FieldDefinitionEnum.Agreement.ToType().GetFieldDefinitionLabel()} {agreement.AgreementNumber}",
                SaveFiltersInCookie = true
            };
            BasicCostAuthorityGridDataUrl = SitkaRoute <AgreementController> .BuildUrlFromExpression(ac => ac.AgreementCostAuthorityGridJsonData(agreement));
        }
예제 #4
0
        /// <summary>
        /// For existing (edit)
        /// </summary>
        /// <param name="optionalAgreement">Optional Agreement. Use null if all-new Agreement</param>
        public AgreementEditViewData(ProjectFirmaModels.Models.Agreement optionalAgreement)
        {
            var availableUnassociatedObligationNumbers = HttpRequestStorage.DatabaseEntities.ObligationNumbers.Where(oNum => !oNum.ReclamationAgreementID.HasValue).ToList();

            if (optionalAgreement != null)
            {
                var alreadySetObligationNumber = optionalAgreement.ObligationNumbersWhereYouAreTheReclamationAgreement.SingleOrDefault();
                // Also include Obligation we are already hooked to if Agreement is provided
                if (alreadySetObligationNumber != null)
                {
                    availableUnassociatedObligationNumbers.Add(alreadySetObligationNumber);
                }
            }
            ObligationNumberSelectListItems = availableUnassociatedObligationNumbers.OrderBy(uo => uo.ObligationNumberKey).ToSelectListWithEmptyFirstRow(oNum => oNum.ObligationNumberID.ToString(CultureInfo.InvariantCulture), x => x.ObligationNumberKey);

            var activeOrganizations = HttpRequestStorage.DatabaseEntities.Organizations.GetActiveOrganizations();

            OrganizationSelectListItems = activeOrganizations.OrderBy(ao => ao.OrganizationName).ToSelectListWithEmptyFirstRow(x => x.OrganizationID.ToString(CultureInfo.InvariantCulture), x => x.OrganizationName);

            var allContractTypes = HttpRequestStorage.DatabaseEntities.ContractTypes.ToList();

            ContractTypeSelectListItems = allContractTypes.OrderBy(x => x.ContractTypeDisplayName).ToSelectListWithEmptyFirstRow(x => x.ContractTypeID.ToString(), x => x.ContractTypeDisplayName);
        }
예제 #5
0
 private void SetUpAgreementEditViewData(ProjectFirmaModels.Models.Agreement optionalAgreement)
 {
 }
예제 #6
0
        private void BasicProjectInfoGridSpec_Impl(FirmaSession currentFirmaSession,
                                                   bool allowTaggingFunctionality,
                                                   ProjectFirmaModels.Models.CostAuthority costAuthorityWorkBreakdownStructure,
                                                   ProjectFirmaModels.Models.Agreement agreement)
        {
            var userHasTagManagePermissions = new FirmaAdminFeature().HasPermissionByFirmaSession(currentFirmaSession);

            if (userHasTagManagePermissions && allowTaggingFunctionality)
            {
                BulkTagModalDialogForm = new BulkTagModalDialogForm(
                    SitkaRoute <TagController> .BuildUrlFromExpression(x => x.BulkTagProjects(null)),
                    $"Tag Checked {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabelPluralized()}",
                    $"Tag {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabelPluralized()}");
                AddCheckBoxColumn();
                Add("ProjectID", x => x.ProjectID, 0);
            }

            Add(string.Empty,
                x => UrlTemplate.MakeHrefString(x.GetFactSheetUrl(), FirmaDhtmlxGridHtmlHelpers.FactSheetIcon.ToString()), 30,
                DhtmlxGridColumnFilterType.None);
            Add(FieldDefinitionEnum.ProjectName.ToType().ToGridHeaderString(), x => UrlTemplate.MakeHrefString(x.GetDetailUrl(), x.ProjectName), 300, DhtmlxGridColumnFilterType.Html);
            if (costAuthorityWorkBreakdownStructure != null)
            {
                Add($"Is {costAuthorityWorkBreakdownStructure.GetDisplayName()} Primary or Secondary CAWBS for this project?",
                    x => x.CostAuthorityProjects.Any(rcap =>
                                                     rcap.IsPrimaryProjectCawbs && rcap.CostAuthorityID ==
                                                     costAuthorityWorkBreakdownStructure.CostAuthorityID)
                        ? "Primary"
                        : "Secondary", 70, DhtmlxGridColumnFilterType.SelectFilterStrict);
            }

            if (agreement != null)
            {
                Add(FieldDefinitionEnum.PrimaryCostAuthorityWorkBreakdownStructure.ToType().ToGridHeaderString(), x => x.CostAuthorityProjects.SingleOrDefault(rcap => rcap.IsPrimaryProjectCawbs)?.CostAuthority.GetDetailLinkUsingCostAuthorityWorkBreakdownStructure(), 120, DhtmlxGridColumnFilterType.Html);

                Add(FieldDefinitionEnum.SecondaryCostAuthorityWorkBreakdownStructure.ToType().ToGridHeaderStringPlural(), x => GetSecondaryCostAuthorityAsCommaDelimitedList(x), 200, DhtmlxGridColumnFilterType.Text);
            }

            if (MultiTenantHelpers.HasCanStewardProjectsOrganizationRelationship())
            {
                Add(FieldDefinitionEnum.ProjectsStewardOrganizationRelationshipToProject.ToType().ToGridHeaderString(),
                    x => x.GetCanStewardProjectsOrganization().GetShortNameAsUrl(), 150,
                    DhtmlxGridColumnFilterType.Html);
            }

            Add(FieldDefinitionEnum.IsPrimaryContactOrganization.ToType().ToGridHeaderString(),
                x => x.GetPrimaryContactOrganization().GetShortNameAsUrl(), 150, DhtmlxGridColumnFilterType.Html);
            Add(FieldDefinitionEnum.ProjectStage.ToType().ToGridHeaderString(), x => x.ProjectStage.ProjectStageDisplayName, 90,
                DhtmlxGridColumnFilterType.SelectFilterStrict);
            Add(FieldDefinitionEnum.PlanningDesignStartYear.ToType().ToGridHeaderString(), x => x.GetPlanningDesignStartYear(),
                90, DhtmlxGridColumnFilterType.SelectFilterStrict);
            Add(FieldDefinitionEnum.ImplementationStartYear.ToType().ToGridHeaderString(), x => x.GetImplementationStartYear(),
                115, DhtmlxGridColumnFilterType.SelectFilterStrict);
            Add(FieldDefinitionEnum.CompletionYear.ToType().ToGridHeaderString(), x => x.GetCompletionYear(), 90,
                DhtmlxGridColumnFilterType.SelectFilterStrict);
            Add(FieldDefinitionEnum.FundingType.ToType().ToGridHeaderString(),
                x => x.FundingType?.FundingTypeDisplayName ?? string.Empty, 300, DhtmlxGridColumnFilterType.SelectFilterStrict);
            Add(FieldDefinitionEnum.EstimatedTotalCost.ToType().ToGridHeaderString(),
                x => x.GetEstimatedTotalRegardlessOfFundingType(), 110, DhtmlxGridColumnFormatType.Currency,
                DhtmlxGridColumnAggregationType.Total);

            Add(FieldDefinitionEnum.ProjectedFunding.ToType().ToGridHeaderString(), x => x.GetProjectedFunding(), 100,
                DhtmlxGridColumnFormatType.Currency, DhtmlxGridColumnAggregationType.Total);
            Add(FieldDefinitionEnum.NoFundingSourceIdentified.ToType().ToGridHeaderString(),
                x => x.GetNoFundingSourceIdentifiedAmount(), 110, DhtmlxGridColumnFormatType.Currency,
                DhtmlxGridColumnAggregationType.Total);
            foreach (var geospatialAreaType in new List <GeospatialAreaType>())
            {
                Add($"{geospatialAreaType.GeospatialAreaTypeNamePluralized}",
                    a => a.GetProjectGeospatialAreaNamesAsHyperlinks(geospatialAreaType), 350, DhtmlxGridColumnFilterType.Html);
            }

            Add(FieldDefinitionEnum.ProjectDescription.ToType().ToGridHeaderString(), x => x.ProjectDescription, 300);
            if (userHasTagManagePermissions)
            {
                Add("Tags",
                    x => new HtmlString(!x.ProjectTags.Any()
                        ? string.Empty
                        : string.Join(", ", x.ProjectTags.Select(pt => pt.Tag.GetDisplayNameAsUrl()))), 100,
                    DhtmlxGridColumnFilterType.Html);
            }
        }
예제 #7
0
 public BasicProjectInfoGridSpec(FirmaSession currentFirmaSession, bool allowTaggingFunctionality, ProjectFirmaModels.Models.Agreement agreement)
 {
     BasicProjectInfoGridSpec_Impl(currentFirmaSession, allowTaggingFunctionality, null, agreement);
 }
 public static void DeleteAgreement(this IQueryable <Agreement> agreements, Agreement agreementToDelete)
 {
     DeleteAgreement(agreements, new List <Agreement> {
         agreementToDelete
     });
 }