Skip to content

Commit

Permalink
fix regional distribution "break-bug"
Browse files Browse the repository at this point in the history
  • Loading branch information
AneMarlene committed Dec 6, 2023
1 parent 2708e09 commit f67ee35
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
22 changes: 1 addition & 21 deletions Prod.Api/Helpers/ExportMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public static Mapper InitializeMapper()
opt.PreCondition(src => src.References is not null & src.References.Count != 0);
opt.MapFrom(src => string.Join(" && ", src.References.Select(x => x.FormattedReference)));
})
.ForMember(dest => dest.RegionalDistribution, opt => opt.MapFrom(src => ExportMapperHelper.GetRegionalDistribution(src.Fylkesforekomster)))

.AfterMap((src, dest) =>
{
Expand Down Expand Up @@ -196,7 +197,6 @@ public static Mapper InitializeMapper()
dest.IntroNatureFreqNumTime = GetIntroSpreadInfo(src.AssesmentVectors, "intro", "freqs");
dest.SpreadNatureMainCatAndCat = GetIntroSpreadInfo(src.AssesmentVectors, "spread", "cat");
dest.SpreadNatureFreqNumTime = GetIntroSpreadInfo(src.AssesmentVectors, "spread", "freqs");
dest.RegionalDistribution = GetRegionalDistribution(src.Fylkesforekomster);
dest.IntroductionsLow = introductionsLow(src, src.RiskAssessment);
dest.IntroductionsHigh = introductionsHigh(src, src.RiskAssessment);
dest.AOO10yrBest = AOO10yrBest(src, src.RiskAssessment);
Expand Down Expand Up @@ -514,26 +514,6 @@ private static string GetimpactedNatureTypes(List<FA4.ImpactedNatureType> impact
// return AlienSpeciesCat[AlienCat];
// }

private static string GetRegionalDistribution(List<Fylkesforekomst> fylkesforekomster)
{
if (fylkesforekomster == null || fylkesforekomster.Count == 0)
{
return string.Empty;
}
var fylkesliste = new List<string>();
for (var i = 0; i < fylkesforekomster.Count; ++i)
{
if (fylkesforekomster[i].State0 == 0 && fylkesforekomster[i].State1 == 0 && fylkesforekomster[i].State3 == 0)
{
break;
}

string newreg = fylkesforekomster[i].Fylke + "//" + fylkesforekomster[i].State0 + "//" + fylkesforekomster[i].State1 + "//" + fylkesforekomster[i].State3;
fylkesliste.Add(newreg);

}
return string.Join("; ", fylkesliste);
}

private static string GetIndoorProduction(string indoorPathway, List<Domain.MigrationPathway> importPathways, string col)
{
Expand Down
18 changes: 18 additions & 0 deletions Prod.Api/Helpers/ExportMapperHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -393,5 +393,23 @@ internal static string GetRiskAssessmentChosenMethodBcrit(RiskAssessment ra, str
(scoretab == "low") ? CritLow :
CritHigh;
}
internal static string GetRegionalDistribution(List<Fylkesforekomst> fylkesforekomster)
{
if (fylkesforekomster == null || fylkesforekomster.Count == 0)
{
return string.Empty;
}
var regionList = new List<string>();
for (var i = 0; i < fylkesforekomster.Count; ++i)
{
if (fylkesforekomster[i].State0 != 0 || fylkesforekomster[i].State1 != 0 || fylkesforekomster[i].State3 != 0)
{
string newreg = fylkesforekomster[i].Fylke + "//" + fylkesforekomster[i].State0 + "//" + fylkesforekomster[i].State1 + "//" + fylkesforekomster[i].State3;
regionList.Add(newreg);
}

}
return string.Join("; ", regionList);
}
}
}

0 comments on commit f67ee35

Please sign in to comment.