Example #1
0
        public IEnumerable <ValidationResult> GetValidationResults()
        {
            var errors = new List <ValidationResult>();
            var noPriorityLandscapesSelected = PriorityLandscapeIDs == null || PriorityLandscapeIDs.Count().Equals(0);

            if (noPriorityLandscapesSelected && string.IsNullOrWhiteSpace(NoPriorityLandscapesExplanation))
            {
                errors.Add(
                    new SitkaValidationResult <EditProjectPriorityLandscapesViewModel, string>(
                        "Select at least one priority landscape or provide explanatory information in the Notes section if there are no applicable priority areas for this Project.",
                        x => x.NoPriorityLandscapesExplanation));
            }

            return(errors);
        }
Example #2
0
        public void UpdateModel(ProjectUpdateBatch project, List <ProjectPriorityLandscapeUpdate> currentProjectPriorityLandscapes, IList <ProjectPriorityLandscapeUpdate> allProjectPriorityLandscapes)
        {
            var newProjectPriorityLandscapes = PriorityLandscapeIDs?.Select(x => new ProjectPriorityLandscapeUpdate(project.ProjectUpdateBatchID, x)).ToList() ?? new List <ProjectPriorityLandscapeUpdate>();

            currentProjectPriorityLandscapes.Merge(newProjectPriorityLandscapes, allProjectPriorityLandscapes, (x, y) => x.ProjectUpdateBatchID == y.ProjectUpdateBatchID && x.PriorityLandscapeID == y.PriorityLandscapeID);
        }