Skip to content
This repository has been archived by the owner on Jan 28, 2022. It is now read-only.

Commit

Permalink
FIX Nullpointer exception in CountryCodeType
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalsigi committed Apr 19, 2019
1 parent e7fb8d0 commit ccd676f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
10 changes: 8 additions & 2 deletions eRechnungWordPlugIn/ebIModels/Models/CountryCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public static class CountryCodes
{
private static List<CountryCodeModel> _countryCodes;
private const string CountryCodeXml = "iso_3166-1_laender.xml";
private static CountryCodeModel DefaultCountryCode = new CountryCodeModel();
private static void LoadCountryCodes()
{
IResourceService xmlRes = new ResourceService();
Expand All @@ -27,6 +28,11 @@ private static void LoadCountryCodes()
Code = xElement.Element("Shortcut").Value,
Country = getCountry(xElement.Element("Land").Value)
}).ToList<CountryCodeModel>();
DefaultCountryCode = GetFromCode("AT");
if (DefaultCountryCode==null)
{
DefaultCountryCode = _countryCodes[0];
}
}
public static List<CountryCodeModel> GetCountryCodeList()
{
Expand All @@ -35,11 +41,11 @@ public static List<CountryCodeModel> GetCountryCodeList()
return _countryCodes;
}

public static CountryCodeModel GetFromCode(string country)
public static CountryCodeModel GetFromCode(string countryCode)
{
if (_countryCodes == null)
LoadCountryCodes();
var cText = _countryCodes.FirstOrDefault(p => p.Code == country.ToString());
var cText = _countryCodes.FirstOrDefault(p => p.Code == countryCode.ToString());
return cText;
}

Expand Down
11 changes: 6 additions & 5 deletions eRechnungWordPlugIn/ebIModels/Models/InvoiceModelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,20 +281,21 @@ public string GetFurtherIdentification(FurtherIdentificationType.SupportedIds id
}
public partial class CountryType
{

// private readonly ICountryCodes _countryCodes = new CountryCodesModels();
public CountryType(CountryCodeType country)
{
{
var cText = CountryCodes.GetFromCode(country.ToString());
countryCodeField = country.ToString();
valueField = cText?.Country;
}
public string CountryCodeText
{
get {
return CountryCode?.ToString();
return CountryCode;
}
set {
if (CountryCode.ToString().Equals(value) == true)
return;
string val = value;
string val = value??"AT";
CountryCode = ((CountryCodeType)Enum.Parse(typeof(CountryCodeType), val)).ToString();
}
}
Expand Down
6 changes: 3 additions & 3 deletions eRechnungWordPlugIn/ebIModels/XmlData/ProductInfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<Title>ebInterface 5.0.3 Word PlugIn</Title>
<Version>5.0.4+4</Version>
<CompileInfo>Debug</CompileInfo>
<CompileTime>2019-04-12 16:13:01</CompileTime>
<CompileTime>2019-04-19 09:58:28</CompileTime>
<Branch>TestBuild</Branch>
<LastCommit>2019-04-12 16:13:01</LastCommit>
<ChangeSetId>ff3e4c5</ChangeSetId>
<LastCommit>2019-04-19 09:58:28</LastCommit>
<ChangeSetId>e7fb8d0</ChangeSetId>
</ProductInfo>

0 comments on commit ccd676f

Please sign in to comment.