SelectListViewModel tostring fix

Fix for links in the details to the right controller
This commit is contained in:
2020-10-03 21:59:58 -04:00
parent 4b44128d62
commit 6a5b37eda9
2 changed files with 7 additions and 3 deletions
+5 -1
View File
@@ -10,7 +10,7 @@ namespace MileageTraker.Web.ViewModels
public override string ToString()
{
if (Selected > 0)
if (Selected.HasValue && Selected.Value > 0 && Available != null)
{
var selected = Available.FirstOrDefault(i => i.Value == Selected.ToString());
if (selected != null)
@@ -18,6 +18,10 @@ namespace MileageTraker.Web.ViewModels
return selected.Text;
}
}
else if (Selected.HasValue)
{
return Selected.ToString();
}
return string.Empty;
}
}