public static WaterObject MapToWaterObject(this RiverFeatureProperties feature) { try { var waterObject = new WaterObject() { Id = Guid.NewGuid(), Name = feature.NameUkr, CodeSwb = feature.CodeSwb, CreatedOn = DateTime.UtcNow, Category = feature.Category, TypeName = feature.TypeName, TypeCode = feature.TypeCode, Note = feature.NoteUkr, Description = GetRiverDescription(feature), Type = WaterObjectType.River }; return(waterObject); } catch (Exception exception) { ConsoleLogger.WriteError($"Exception occured while mapping the river feature {feature}.", exception); throw exception; } }
private static string GetRiverDescription(RiverFeatureProperties riverProperties) { try { var descriptionBuilder = new StringBuilder(); if (riverProperties.LengthKm.HasValue) { descriptionBuilder.Append($"Довжина (км): {riverProperties.LengthKm}."); } if (!string.IsNullOrEmpty(riverProperties.FlowTo)) { descriptionBuilder.Append($" Впадає в: { riverProperties.FlowTo}."); } return(descriptionBuilder.ToString()); } catch (Exception exception) { ConsoleLogger.WriteWarning($"Could not generate a description for river {riverProperties}.", exception); return(string.Empty); } }