public IEnumerable <ValidationResult> GetValidationResults() { var errors = new List <ValidationResult>(); var noRegionsSelected = DNRUplandRegionIDs == null || DNRUplandRegionIDs.Count().Equals(0); if (noRegionsSelected && string.IsNullOrWhiteSpace(NoDNRUplandRegionsExplanation)) { errors.Add( new SitkaValidationResult <EditProjectRegionsViewModel, string>( $"Select at least one {Models.FieldDefinition.DNRUplandRegion.GetFieldDefinitionLabel()} or provide explanatory information in the Notes section if there are no applicable {Models.FieldDefinition.DNRUplandRegion.GetFieldDefinitionLabelPluralized()} for this Project.", x => x.NoDNRUplandRegionsExplanation)); } return(errors); }
public void UpdateModel(ProjectUpdateBatch project, List <ProjectRegionUpdate> currentProjectRegions, IList <ProjectRegionUpdate> allProjectRegions) { var newProjectRegions = DNRUplandRegionIDs?.Select(x => new ProjectRegionUpdate(project.ProjectUpdateBatchID, x)).ToList() ?? new List <ProjectRegionUpdate>(); currentProjectRegions.Merge(newProjectRegions, allProjectRegions, (x, y) => x.ProjectUpdateBatchID == y.ProjectUpdateBatchID && x.DNRUplandRegionID == y.DNRUplandRegionID); }
public void UpdateModel(Models.Project project, List <Models.ProjectRegion> currentProjectRegions, IList <Models.ProjectRegion> allProjectRegions) { var newProjectRegions = DNRUplandRegionIDs?.Select(x => new Models.ProjectRegion(project.ProjectID, x)).ToList() ?? new List <Models.ProjectRegion>(); currentProjectRegions.Merge(newProjectRegions, allProjectRegions, (x, y) => x.ProjectID == y.ProjectID && x.DNRUplandRegionID == y.DNRUplandRegionID); }