public void UpdateModel(ProjectFirmaModels.Models.ProjectUpdate projectUpdate, FirmaSession currentFirmaSession) { projectUpdate.ProjectDescription = ProjectDescription; projectUpdate.ProjectStageID = ProjectStageID; projectUpdate.PlanningDesignStartYear = PlanningDesignStartYear; projectUpdate.ImplementationStartYear = ImplementationStartYear; projectUpdate.CompletionYear = CompletionYear; }
public BasicsViewModel(ProjectFirmaModels.Models.ProjectUpdate projectUpdate, string comments) { ProjectDescription = projectUpdate.ProjectDescription; ProjectStageID = projectUpdate.ProjectStageID; PlanningDesignStartYear = projectUpdate.PlanningDesignStartYear; ImplementationStartYear = projectUpdate.ImplementationStartYear; CompletionYear = projectUpdate.CompletionYear; Comments = comments; }
public ProjectCustomAttributesValidationResult(ProjectFirmaModels.Models.ProjectUpdate projectUpdate, FirmaSession currentFirmaSession) { _warningMessages = new List <string>(); // Validate that required Custom Attributes are present var requiredCustomAttributeTypeIDs = HttpRequestStorage.DatabaseEntities.ProjectCustomAttributeTypes.Where(x => x.IsRequired && x.ProjectCustomAttributeGroup.ProjectCustomAttributeGroupProjectCategories.Any(pcagpt => pcagpt.ProjectCategoryID == projectUpdate.ProjectCategoryID)).ToList().Where(x => x.HasEditPermission(currentFirmaSession)).Select(x => x.ProjectCustomAttributeTypeID).ToList(); var projectrequiredCustomAttributeTypeIDs = projectUpdate.GetProjectCustomAttributes().Where(x => x.ProjectCustomAttributeType.IsRequired).Select(x => x.ProjectCustomAttributeTypeID).ToList(); if (requiredCustomAttributeTypeIDs.Any(x => !projectrequiredCustomAttributeTypeIDs.Contains(x))) { _warningMessages.Add(FirmaValidationMessages.RequiredCustomAttribute); } }
public BasicsValidationResult(ProjectFirmaModels.Models.ProjectUpdate projectUpdate) { _warningMessages = new List <string>(); if (projectUpdate.PlanningDesignStartYear == null) { _warningMessages.Add(PlanningDesignStartYearIsRequired); } if (projectUpdate.ImplementationStartYear == null && projectUpdate.ProjectStage != ProjectStage.Terminated && projectUpdate.ProjectStage != ProjectStage.Deferred) { _warningMessages.Add(ImplementationStartYearIsRequired); } if ((projectUpdate.ProjectStage == ProjectStage.Completed || projectUpdate.ProjectStage == ProjectStage.PostImplementation) && projectUpdate.CompletionYear == null) { _warningMessages.Add(CompletionYearIsRequired); } if (GeneralUtility.IsNullOrEmptyOrOnlyWhitespace(projectUpdate.ProjectDescription)) { _warningMessages.Add(ProjectDescriptionIsRequired); } var currentYear = FirmaDateUtilities.CalculateCurrentYearToUseForUpToAllowableInputInReporting(); if ((projectUpdate.ProjectStage == ProjectStage.Completed || projectUpdate.ProjectStage == ProjectStage.PostImplementation) && projectUpdate.CompletionYear > currentYear) { _warningMessages.Add(CompletionYearShouldBeLessThanCurrentYear); } if (projectUpdate.ProjectStage == ProjectStage.PlanningDesign && projectUpdate.PlanningDesignStartYear > currentYear) { _warningMessages.Add(PlanningDesignStartYearShouldBeLessThanCurrentYear); } if (projectUpdate.ProjectStage == ProjectStage.Implementation && projectUpdate.ImplementationStartYear > currentYear) { _warningMessages.Add(ImplementationStartYearShouldBeLessThanCurrentYear); } if (projectUpdate.ImplementationStartYear < projectUpdate.PlanningDesignStartYear) { _warningMessages.Add(FirmaValidationMessages.ImplementationStartYearGreaterThanPlanningDesignStartYear); } if (projectUpdate.CompletionYear < projectUpdate.ImplementationStartYear) { _warningMessages.Add(FirmaValidationMessages.CompletionYearGreaterThanEqualToImplementationStartYear); } if (projectUpdate.CompletionYear < projectUpdate.PlanningDesignStartYear) { _warningMessages.Add(FirmaValidationMessages.CompletionYearGreaterThanEqualToPlanningDesignStartYear); } }
public GeospatialAreaViewData(FirmaSession currentFirmaSession, ProjectFirmaModels.Models.ProjectUpdate projectUpdate, EditProjectGeospatialAreasViewData editProjectGeospatialAreasViewData, ProjectLocationSummaryViewData projectLocationSummaryViewData, GeospatialAreaValidationResult geospatialAreaValidationResult, ProjectUpdateStatus projectUpdateStatus, GeospatialAreaType geospatialAreaType) : base(currentFirmaSession, projectUpdate.ProjectUpdateBatch, projectUpdateStatus, geospatialAreaValidationResult.GetWarningMessages(), geospatialAreaType.GeospatialAreaTypeNamePluralized) { EditProjectGeospatialAreasViewData = editProjectGeospatialAreasViewData; ProjectLocationSummaryViewData = projectLocationSummaryViewData; RefreshUrl = SitkaRoute <ProjectUpdateController> .BuildUrlFromExpression(x => x.RefreshProjectGeospatialArea(projectUpdate.ProjectUpdateBatch.Project, geospatialAreaType)); SectionCommentsViewData = new SectionCommentsViewData(projectUpdate.ProjectUpdateBatch.LocationSimpleComment, projectUpdate.ProjectUpdateBatch.IsReturned()); GeospatialAreaType = geospatialAreaType; }
public LocationSimpleViewData(FirmaSession currentFirmaSession, ProjectFirmaModels.Models.ProjectUpdate projectUpdate, ProjectLocationSimpleViewData projectLocationSimpleViewData, ProjectLocationSummaryViewData projectLocationSummaryViewData, LocationSimpleValidationResult locationSimpleValidationResult, ProjectUpdateStatus projectUpdateStatus) : base(currentFirmaSession, projectUpdate.ProjectUpdateBatch, projectUpdateStatus, locationSimpleValidationResult.GetWarningMessages(), ProjectUpdateSection.LocationSimple.ProjectUpdateSectionDisplayName) { ProjectLocationSimpleViewData = projectLocationSimpleViewData; ProjectLocationSummaryViewData = projectLocationSummaryViewData; RefreshUrl = SitkaRoute <ProjectUpdateController> .BuildUrlFromExpression(x => x.RefreshProjectLocationSimple(projectUpdate.ProjectUpdateBatch.Project)); SectionCommentsViewData = new SectionCommentsViewData( projectUpdate.ProjectUpdateBatch.LocationSimpleComment, projectUpdate.ProjectUpdateBatch.IsReturned()); ValidationWarnings = locationSimpleValidationResult.GetWarningMessages(); }
public void UpdateModel(ProjectUpdate projectUpdate, FirmaSession currentFirmaSession) { FixUpMissingBooleansToBeFalse(); var allProjectCustomAttributeTypes = HttpRequestStorage.DatabaseEntities.ProjectCustomAttributeTypes.ToList(); var existingProjectCustomAttributes = projectUpdate.ProjectUpdateBatch.ProjectCustomAttributeUpdates.Where(x => x.ProjectCustomAttributeType.HasEditPermission(currentFirmaSession)).ToList(); var customAttributesToUpdate = Attributes.Where(x => x.ProjectCustomAttributeValues != null && x.ProjectCustomAttributeValues.Any(y => !string.IsNullOrWhiteSpace(y))) .Select(x => new ProjectCustomAttributeUpdate(projectUpdate.ProjectUpdateBatchID, x.ProjectCustomAttributeTypeID)) .ToList(); var existingProjectCustomAttributeValues = existingProjectCustomAttributes.SelectMany(x => x.ProjectCustomAttributeUpdateValues).ToList(); var customAttributeValuesToUpdate = customAttributesToUpdate.Join(Attributes, x => x.ProjectCustomAttributeTypeID, x => x.ProjectCustomAttributeTypeID, (a, b) => { // Use existing attribute ID if you can, otherwise use dummy entity ID var projectCustomAttributeUpdateID = existingProjectCustomAttributes .SingleOrDefault(x => x.ProjectCustomAttributeTypeID == a.ProjectCustomAttributeTypeID) ?.ProjectCustomAttributeUpdateID ?? a.ProjectCustomAttributeUpdateID; var projectCustomAttributeType = allProjectCustomAttributeTypes.Single(x => x.ProjectCustomAttributeTypeID == a.ProjectCustomAttributeTypeID); return(b.ProjectCustomAttributeValues .Select(x => { var attributeValue = projectCustomAttributeType.ProjectCustomAttributeDataType .ValueParsedForDataType(x); return new ProjectCustomAttributeUpdateValue(projectCustomAttributeUpdateID, attributeValue); }) .ToList()); }) .SelectMany(x => x) .ToList(); UpdateProjectCustomAttributesImpl(existingProjectCustomAttributes, customAttributesToUpdate, HttpRequestStorage.DatabaseEntities.AllProjectCustomAttributeUpdates.Local); UpdateProjectCustomAttributeValuesImpl(existingProjectCustomAttributeValues, customAttributeValuesToUpdate, HttpRequestStorage.DatabaseEntities.AllProjectCustomAttributeUpdateValues.Local); }
public BasicsViewData(FirmaSession currentFirmaSession , ProjectFirmaModels.Models.ProjectUpdate projectUpdate, IEnumerable <ProjectStage> projectStages , ProjectUpdateStatus projectUpdateStatus, BasicsValidationResult basicsValidationResult) : base(currentFirmaSession, projectUpdate.ProjectUpdateBatch, projectUpdateStatus, basicsValidationResult.GetWarningMessages(), ProjectUpdateSection.Basics.ProjectUpdateSectionDisplayName) { ProjectUpdate = projectUpdate; TaxonomyLeafDisplayName = projectUpdate.ProjectUpdateBatch.Project.TaxonomyLeaf.GetDisplayName(); ProjectStages = projectStages.OrderBy(x => x.SortOrder).ToSelectListWithEmptyFirstRow(x => x.ProjectStageID.ToString(CultureInfo.InvariantCulture), y => y.ProjectStageDisplayName); ProjectStagesModels = projectStages; PlanningDesignStartYearRange = FirmaDateUtilities.YearsForUserInput().ToSelectListWithEmptyFirstRow(x => x.CalendarYear.ToString(CultureInfo.InvariantCulture), x => x.CalendarYearDisplay).ToList(); ImplementationStartYearRange = FirmaDateUtilities.YearsForUserInput().ToSelectListWithEmptyFirstRow(x => x.CalendarYear.ToString(CultureInfo.InvariantCulture), x => x.CalendarYearDisplay).ToList(); CompletionYearRange = FirmaDateUtilities.YearsForUserInput().ToSelectListWithEmptyFirstRow(x => x.CalendarYear.ToString(CultureInfo.InvariantCulture), x => x.CalendarYearDisplay).ToList(); RefreshUrl = SitkaRoute <ProjectUpdateController> .BuildUrlFromExpression(x => x.RefreshBasics(Project)); DiffUrl = SitkaRoute <ProjectUpdateController> .BuildUrlFromExpression(x => x.DiffBasics(Project)); SectionCommentsViewData = new SectionCommentsViewData(projectUpdate.ProjectUpdateBatch.BasicsComment, projectUpdate.ProjectUpdateBatch.IsReturned()); StartYearForTotalCostCalculation = projectUpdate.StartYearForTotalCostCalculations(); TenantUsesFiscalYears = MultiTenantHelpers.UseFiscalYears(); }