private string GetValidationEntityName(WorkReportCsvDto untypedRow, ActivityCodeDto activityCode) { var locationCode = activityCode.LocationCode; string entityName; if (locationCode.LocationCode == "C") { if ((untypedRow.StartLatitude.IsEmpty() || untypedRow.StartLongitude.IsEmpty()) && !(untypedRow.StartOffset.IsEmpty() || untypedRow.EndOffset.IsEmpty())) { entityName = Entities.WorkReportD4; untypedRow.SpatialData = SpatialData.Lrs; } else { entityName = Entities.WorkReportD3; untypedRow.SpatialData = SpatialData.Gps; } } else { entityName = Entities.WorkReportD2; untypedRow.SpatialData = SpatialData.None; } return(entityName); }
private void PerformFieldValidation(Dictionary <string, List <string> > errors, WorkReportCsvDto untypedRow, ActivityCodeDto activityCode) { if (activityCode.LocationCode.LocationCode == "C" && activityCode.ActivityNumber.StartsWith('6')) { _validator.Validate(Entities.WorkReportStructure, Fields.StructureNumber, untypedRow.StructureNumber, errors); } if (activityCode.IsSiteNumRequired) { _validator.Validate(Entities.WorkReportSite, Fields.SiteNumber, untypedRow.SiteNumber, errors); } if (untypedRow.SpatialData == SpatialData.None && activityCode.LocationCode.LocationCode == "B") { _validator.Validate(Entities.WorkReportHighwayUnique, Fields.HighwayUnique, untypedRow.HighwayUnique, errors); } if (untypedRow.RecordType == "Q") { _validator.Validate(Entities.WorkReportValueOfWork, Fields.ValueOfWork, untypedRow.ValueOfWork, errors); } if (untypedRow.UnitOfMeasure.ToLowerInvariant() != activityCode.UnitOfMeasure.ToLowerInvariant()) { errors.AddItem(Fields.UnitOfMeasure, $"Unit of measure for the activity Code [{activityCode.ActivityNumber}] must be [{activityCode.UnitOfMeasure}]"); } if (untypedRow.RecordType.ToLowerInvariant() != activityCode.MaintenanceType.ToLowerInvariant()) { errors.AddItem(Fields.RecordType, $"Record type of the activity code [{activityCode.ActivityNumber}] must be [{activityCode.MaintenanceType}]"); } }