public ProjectAttributeValidationResult(Models.ProjectUpdate projectUpdate)
        {
            var potentialWarnings = new List <string>();

            new CustomAttributesViewModel(projectUpdate).GetValidationResults(out potentialWarnings);
            _warningMessages = potentialWarnings;
        }
Ejemplo n.º 2
0
 public void UpdateModel(Models.ProjectUpdate projectUpdate, Person currentPerson)
 {
     projectUpdate.ProjectDescription = ProjectDescription;
     projectUpdate.ProjectStageID     = ProjectStageID;
     projectUpdate.PlannedDate        = PlannedDate;
     projectUpdate.ExpirationDate     = ExpirationDate;
     projectUpdate.CompletionDate     = CompletionDate;
     projectUpdate.FocusAreaID        = FocusAreaID;
 }
Ejemplo n.º 3
0
 public BasicsViewModel(Models.ProjectUpdate projectUpdate, string comments)
 {
     ProjectDescription = projectUpdate.ProjectDescription;
     ProjectStageID     = projectUpdate.ProjectStageID;
     PlannedDate        = projectUpdate.PlannedDate;
     ExpirationDate     = projectUpdate.ExpirationDate;
     CompletionDate     = projectUpdate.CompletionDate;
     FocusAreaID        = projectUpdate.FocusAreaID;
     Comments           = comments;
     ProjectID          = projectUpdate.ProjectUpdateBatch.ProjectID;
     ProjectTypeID      = projectUpdate.ProjectUpdateBatch.Project.ProjectTypeID;
 }
Ejemplo n.º 4
0
        public DNRUplandRegionsViewData(Person currentPerson,
                                        Models.ProjectUpdate projectUpdate,
                                        EditProjectRegionsViewData editProjectRegionsViewData,
                                        ProjectLocationSummaryViewData projectLocationSummaryViewData,
                                        DNRUplandRegionsValidationResult dnrUplandRegionValidationResult,
                                        UpdateStatus updateStatus) : base(currentPerson, projectUpdate.ProjectUpdateBatch, updateStatus, dnrUplandRegionValidationResult.GetWarningMessages(), ProjectUpdateSection.DNRUplandRegions.ProjectUpdateSectionDisplayName)
        {
            EditProjectRegionsViewData     = editProjectRegionsViewData;
            ProjectLocationSummaryViewData = projectLocationSummaryViewData;
            RefreshUrl = SitkaRoute <ProjectUpdateController> .BuildUrlFromExpression(x => x.RefreshProjectRegion(projectUpdate.ProjectUpdateBatch.Project));

            SectionCommentsViewData = new SectionCommentsViewData(projectUpdate.ProjectUpdateBatch.LocationSimpleComment, projectUpdate.ProjectUpdateBatch.IsReturned);
        }
        public PriorityLandscapesViewData(Person currentPerson,
                                          Models.ProjectUpdate projectUpdate,
                                          EditProjectPriorityLandscapesViewData editProjectPriorityLandscapesViewData,
                                          ProjectLocationSummaryViewData projectLocationSummaryViewData,
                                          PriorityLandscapesValidationResult priorityLandscapeValidationResult,
                                          UpdateStatus updateStatus) : base(currentPerson, projectUpdate.ProjectUpdateBatch, updateStatus, priorityLandscapeValidationResult.GetWarningMessages(), "Priority Landscapes")
        {
            EditProjectPriorityLandscapesViewData = editProjectPriorityLandscapesViewData;
            ProjectLocationSummaryViewData        = projectLocationSummaryViewData;
            RefreshUrl = SitkaRoute <ProjectUpdateController> .BuildUrlFromExpression(x => x.RefreshProjectPriorityLandscape(projectUpdate.ProjectUpdateBatch.Project));

            SectionCommentsViewData = new SectionCommentsViewData(projectUpdate.ProjectUpdateBatch.LocationSimpleComment, projectUpdate.ProjectUpdateBatch.IsReturned);
        }
        public CustomAttributesViewData(Person currentPerson,
                                        Models.ProjectUpdate projectUpdate,
                                        UpdateStatus updateStatus,
                                        ProjectAttributeValidationResult projectAttributeValidationResult,
                                        IEnumerable <Models.ProjectCustomAttributeType> projectCustomAttributeTypes)
            : base(currentPerson, projectUpdate.ProjectUpdateBatch, updateStatus, projectAttributeValidationResult.GetWarningMessages(), ProjectUpdateSection.ProjectAttributes.ProjectUpdateSectionDisplayName)
        {
            ProjectUpdate = projectUpdate;
            DiffUrl       = SitkaRoute <ProjectUpdateController> .BuildUrlFromExpression(x => x.DiffProjectAttributes(Project));

            RefreshUrl = SitkaRoute <ProjectUpdateController> .BuildUrlFromExpression(x => x.RefreshProjectAttributes(Project));

            ProjectCustomAttributeTypes = projectCustomAttributeTypes;
            SectionCommentsViewData     =
                new SectionCommentsViewData(projectUpdate.ProjectUpdateBatch.ProjectAttributesComment, projectUpdate.ProjectUpdateBatch.IsReturned);
        }
Ejemplo n.º 7
0
        public LocationSimpleViewData(Person currentPerson,
                                      Models.ProjectUpdate projectUpdate,
                                      ProjectLocationSimpleViewData projectLocationSimpleViewData,
                                      ProjectLocationSummaryViewData projectLocationSummaryViewData,
                                      LocationSimpleValidationResult locationSimpleValidationResult, UpdateStatus updateStatus) : base(
                currentPerson, projectUpdate.ProjectUpdateBatch, updateStatus,
                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();
        }
Ejemplo n.º 8
0
        public BasicsValidationResult(Models.ProjectUpdate projectUpdate)
        {
            _warningMessages = new List <string>();

            if (projectUpdate.GetImplementationStartYear() == null && projectUpdate.ProjectStage != ProjectStage.Cancelled)
            {
                _warningMessages.Add(ImplementationStartYearIsRequired);
            }

            if ((projectUpdate.ProjectStage == ProjectStage.Completed) && projectUpdate.GetCompletionYear() == null)
            {
                _warningMessages.Add(CompletionDateIsRequired);
            }


            var currentYear = FirmaDateUtilities.CalculateCurrentYearToUseForUpToAllowableInputInReporting();

            if ((projectUpdate.ProjectStage == ProjectStage.Completed) && projectUpdate.GetCompletionYear() > currentYear)
            {
                _warningMessages.Add(CompletionDateShouldBeLessThanCurrentYear);
            }
            if (projectUpdate.ProjectStage == ProjectStage.Planned && projectUpdate.PlannedDate?.Year > currentYear)
            {
                _warningMessages.Add(PlannedDateShouldBeLessThanCurrentYear);
            }
            if (projectUpdate.ProjectStage == ProjectStage.Implementation && projectUpdate.GetImplementationStartYear() > currentYear)
            {
                _warningMessages.Add(ImplementationStartYearShouldBeLessThanCurrentYear);
            }

            if (projectUpdate.GetCompletionYear() < projectUpdate.GetImplementationStartYear())
            {
                _warningMessages.Add(FirmaValidationMessages.CompletionDateGreaterThanEqualToImplementationStartYear);
            }
            if (projectUpdate.GetCompletionYear() < projectUpdate.PlannedDate?.Year)
            {
                _warningMessages.Add(FirmaValidationMessages.CompletionDateGreaterThanEqualToPlannedDate);
            }
        }
Ejemplo n.º 9
0
        public BasicsViewData(Person currentPerson, Models.ProjectUpdate projectUpdate,
                              IEnumerable <ProjectStage> projectStages, UpdateStatus updateStatus,
                              BasicsValidationResult basicsValidationResult,
                              IEnumerable <Models.ProjectCustomAttributeType> projectCustomAttributeTypes, List <Models.FocusArea> focusAreas)
            : base(currentPerson, projectUpdate.ProjectUpdateBatch, updateStatus, basicsValidationResult.GetWarningMessages(), ProjectUpdateSection.Basics.ProjectUpdateSectionDisplayName)
        {
            ProjectUpdate          = projectUpdate;
            ProjectTypeDisplayName = projectUpdate.ProjectUpdateBatch.Project.ProjectType.DisplayName;
            ProjectStages          = projectStages.OrderBy(x => x.SortOrder).ToSelectListWithEmptyFirstRow(x => x.ProjectStageID.ToString(CultureInfo.InvariantCulture), y => y.ProjectStageDisplayName);
            FocusAreas             = focusAreas.OrderBy(x => x.FocusAreaName)
                                     .ToSelectListWithEmptyFirstRow(x => x.FocusAreaID.ToString(CultureInfo.InvariantCulture), y => y.FocusAreaName);
            PlannedDateRange             = FirmaDateUtilities.YearsForUserInput().ToSelectListWithEmptyFirstRow(x => x.CalendarYear.ToString(CultureInfo.InvariantCulture), x => x.CalendarYearDisplay);
            ImplementationStartYearRange = FirmaDateUtilities.YearsForUserInput().ToSelectListWithEmptyFirstRow(x => x.CalendarYear.ToString(CultureInfo.InvariantCulture), x => x.CalendarYearDisplay);
            CompletionDateRange          = FirmaDateUtilities.YearsForUserInput().ToSelectListWithEmptyFirstRow(x => x.CalendarYear.ToString(CultureInfo.InvariantCulture), x => x.CalendarYearDisplay);
            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);

            ProjectCustomAttributeTypes = projectCustomAttributeTypes;
        }
Ejemplo n.º 10
0
        public void UpdateModel(ProjectUpdateBatch projectUpdateBatch,
                                List <ProjectGrantAllocationRequestUpdate> currentProjectGrantAllocationRequestUpdates,
                                IList <ProjectGrantAllocationRequestUpdate> allProjectGrantAllocationRequestUpdates,
                                Models.ProjectUpdate projectUpdate,
                                List <ProjectFundingSourceUpdate> currentProjectFundingSourceUpdates,
                                IList <ProjectFundingSourceUpdate> allProjectFundingSourceUpdates)
        {
            var projectGrantAllocationRequestUpdatesUpdated = new List <ProjectGrantAllocationRequestUpdate>();

            if (ProjectGrantAllocationRequests != null)
            {
                // Completely rebuild the list
                projectGrantAllocationRequestUpdatesUpdated = ProjectGrantAllocationRequests.Select(x => x.ToProjectGrantAllocationRequestUpdate()).ToList();
            }

            currentProjectGrantAllocationRequestUpdates.Merge(projectGrantAllocationRequestUpdatesUpdated,
                                                              allProjectGrantAllocationRequestUpdates,
                                                              (x, y) => x.ProjectUpdateBatchID == y.ProjectUpdateBatchID && x.GrantAllocationID == y.GrantAllocationID,
                                                              (x, y) => { x.TotalAmount = y.TotalAmount; });

            //Update the ProjectFundingSourceUpdates
            var projectFundingSourceUpdatesUpdated = new List <Models.ProjectFundingSourceUpdate>();

            if (FundingSourceIDs != null && FundingSourceIDs.Any())
            {
                // Completely rebuild the list
                projectFundingSourceUpdatesUpdated = FundingSourceIDs.Select(x => new ProjectFundingSourceUpdate(projectUpdateBatch.ProjectUpdateBatchID, x)).ToList();
            }

            currentProjectFundingSourceUpdates.Merge(projectFundingSourceUpdatesUpdated,
                                                     allProjectFundingSourceUpdates,
                                                     (x, y) => x.ProjectUpdateBatchID == y.ProjectUpdateBatchID && x.FundingSourceID == y.FundingSourceID);

            //Update Project Update fields
            projectUpdate.ProjectFundingSourceNotes = ProjectFundingSourceNotes;
            projectUpdate.EstimatedTotalCost        = ProjectEstimatedTotalCost;
        }
        public void UpdateModel(ProjectUpdateBatch projectUpdateBatch,
                                List <ProjectGrantAllocationRequestUpdate> currentProjectGrantAllocationRequestUpdates,
                                IList <ProjectGrantAllocationRequestUpdate> allProjectGrantAllocationRequestUpdates,
                                Models.ProjectUpdate projectUpdate,
                                List <ProjectFundingSourceUpdate> currentProjectFundingSourceUpdates,
                                IList <ProjectFundingSourceUpdate> allProjectFundingSourceUpdates)
        {
            var dateNow = DateTime.Now;
            var projectGrantAllocationRequestUpdatesUpdated = new List <ProjectGrantAllocationRequestUpdate>();

            if (ProjectGrantAllocationRequests != null)
            {
                foreach (var projectGrantAllocationRequestSimple in ProjectGrantAllocationRequests)
                {
                    var existingCurrentOne = currentProjectGrantAllocationRequestUpdates.SingleOrDefault(x =>
                                                                                                         x.ProjectUpdateBatchID == projectGrantAllocationRequestSimple.ProjectID &&
                                                                                                         x.GrantAllocationID == projectGrantAllocationRequestSimple.GrantAllocationID);
                    if (existingCurrentOne != null)
                    {
                        var projectGrantAllocationRequestToAdd =
                            projectGrantAllocationRequestSimple.ToProjectGrantAllocationRequestUpdate(
                                existingCurrentOne.CreateDate, dateNow, existingCurrentOne.ImportedFromTabularData);
                        projectGrantAllocationRequestUpdatesUpdated.Add(projectGrantAllocationRequestToAdd);
                    }
                    else
                    {
                        var projectGrantAllocationRequestToAdd =
                            projectGrantAllocationRequestSimple.ToProjectGrantAllocationRequestUpdate(
                                dateNow, null, false);
                        projectGrantAllocationRequestUpdatesUpdated.Add(projectGrantAllocationRequestToAdd);
                    }
                }
            }

            currentProjectGrantAllocationRequestUpdates.Merge(projectGrantAllocationRequestUpdatesUpdated,
                                                              allProjectGrantAllocationRequestUpdates,
                                                              (x, y) => x.ProjectUpdateBatchID == y.ProjectUpdateBatchID && x.GrantAllocationID == y.GrantAllocationID,
                                                              (x, y) =>
            {
                x.TotalAmount             = y.TotalAmount;
                x.MatchAmount             = y.MatchAmount;
                x.PayAmount               = y.PayAmount;
                x.UpdateDate              = y.UpdateDate;
                x.CreateDate              = y.CreateDate;
                x.ImportedFromTabularData = y.ImportedFromTabularData;
            });

            //Update the ProjectFundingSourceUpdates
            var projectFundingSourceUpdatesUpdated = new List <Models.ProjectFundingSourceUpdate>();

            if (FundingSourceIDs != null && FundingSourceIDs.Any())
            {
                // Completely rebuild the list
                projectFundingSourceUpdatesUpdated = FundingSourceIDs.Select(x => new ProjectFundingSourceUpdate(projectUpdateBatch.ProjectUpdateBatchID, x)).ToList();
            }

            currentProjectFundingSourceUpdates.Merge(projectFundingSourceUpdatesUpdated,
                                                     allProjectFundingSourceUpdates,
                                                     (x, y) => x.ProjectUpdateBatchID == y.ProjectUpdateBatchID && x.FundingSourceID == y.FundingSourceID);

            //Update Project Update fields
            projectUpdate.ProjectFundingSourceNotes = ProjectFundingSourceNotes;
            projectUpdate.EstimatedTotalCost        = ProjectEstimatedTotalCost;
        }
 public void UpdateModel(Models.ProjectUpdate projectUpdate, Person person)
 {
     ProjectCustomAttributes?.UpdateModel(projectUpdate, person);
 }
 public CustomAttributesViewModel(Models.ProjectUpdate projectUpdate)
 {
     ProjectTypeID           = projectUpdate.ProjectUpdateBatch.Project.ProjectTypeID;
     ProjectUpdateID         = projectUpdate.ProjectUpdateID;
     ProjectCustomAttributes = new ProjectCustomAttributes(projectUpdate);
 }