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); }
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); }