Skip to content

Commit

Permalink
Add new properties as enums, handle missing enum translations (#1415)
Browse files Browse the repository at this point in the history
  • Loading branch information
eirikn-artsdatabanken committed Jun 7, 2024
1 parent 59b8e52 commit 24316f4
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -685,5 +685,9 @@ public class AlienSpeciesAssessment2023
/// Date of revision of an assessment
/// </summary>
public DateTime RevisionDate { get; set; }

public AlienSpeciesAssessment2023HorizonEstablismentPotential? HorizonEstablismentPotential { get; set; }

public AlienSpeciesAssessment2023HorizonEcologicalEffect? HorizonEcologicalEffect { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Assessments.Mapping.AlienSpecies.Model.Enums;

public enum AlienSpeciesAssessment2023HorizonEcologicalEffect
{
No,
YesWhilePresent,
YesAfterGone
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Assessments.Mapping.AlienSpecies.Model.Enums;

public enum AlienSpeciesAssessment2023HorizonEstablismentPotential
{
Zero = 0,
One = 1,
TwoOrMore = 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,16 @@ public AlienSpeciesAssessment2023Profile()
})
.ForMember(dest => dest.ReasonForChangeOfCategory, opt => opt.MapFrom(src => AlienSpeciesAssessment2023ProfileHelper.GetReasonForChangeOfCategory(src.ReasonForChangeOfCategory)))
.ForMember(dest => dest.RevisionDate, opt => opt.MapFrom(src => AlienSpeciesAssessment2023ProfileHelper.GetRevisionDate(src.Id)))

// horisontskanning
.ForMember(dest => dest.HorizonEstablismentPotential, opt =>
{
opt.PreCondition(src => src.HorizonDoScanning);
})
.ForMember(dest => dest.HorizonEcologicalEffect, opt =>
{
opt.PreCondition(src => src.HorizonDoScanning);
})

.AfterMap((_, dest) => dest.PreviousAssessments = AlienSpeciesAssessment2023ProfileHelper.GetPreviousAssessments(dest.PreviousAssessments));

Expand Down
2 changes: 1 addition & 1 deletion Assessments.Shared/Helpers/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static string DisplayName(this Enum value)
return manager.GetString(attribute.Name);
}
default:
return attribute.Name ?? value.ToString();
return attribute?.Name ?? value.ToString();
}
}

Expand Down

0 comments on commit 24316f4

Please sign in to comment.