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() public override string ToString()
{ {
if (Selected > 0) if (Selected.HasValue && Selected.Value > 0 && Available != null)
{ {
var selected = Available.FirstOrDefault(i => i.Value == Selected.ToString()); var selected = Available.FirstOrDefault(i => i.Value == Selected.ToString());
if (selected != null) if (selected != null)
@@ -18,6 +18,10 @@ namespace MileageTraker.Web.ViewModels
return selected.Text; return selected.Text;
} }
} }
else if (Selected.HasValue)
{
return Selected.ToString();
}
return string.Empty; return string.Empty;
} }
} }
@@ -12,8 +12,8 @@
</div> </div>
<div class="center-content btn-toolbar"> <div class="center-content btn-toolbar">
@Html.ActionLink("Edit", "Edit", new { id = Model.VehicleRecallId }, new { @class = "btn" }) @Html.ActionLink("Edit", "Edit", "VehicleRecall", new { id = Model.VehicleRecallId }, new { @class = "btn" })
@Html.ActionLink("Delete", "Delete", new { id = Model.VehicleId }, new { @class = "btn" }) @Html.ActionLink("Delete", "Delete", "VehicleRecall", new { id = Model.VehicleId }, new { @class = "btn" })
@Html.ActionLink("Vehicle Details", "Details", "Vehicle", new { id = Model.VehicleId }, new{@class="btn"}) @Html.ActionLink("Vehicle Details", "Details", "Vehicle", new { id = Model.VehicleId }, new{@class="btn"})
@Html.ActionLink("Add Service", "Create", "VehicleService", new { VehicleId = Model.VehicleId }, new{@class="btn"}) @Html.ActionLink("Add Service", "Create", "VehicleService", new { VehicleId = Model.VehicleId }, new{@class="btn"})
</div> </div>