Files
MileageTraker/Web/ViewModels/SelectListViewModel.cs
T
poprhythm 6a5b37eda9 SelectListViewModel tostring fix
Fix for links in the details to the right controller
2020-10-03 21:59:58 -04:00

28 lines
723 B
C#

using System.Linq;
using System.Web.Mvc;
namespace MileageTraker.Web.ViewModels
{
public class SelectListViewModel
{
public SelectList Available { get; set; }
public int? Selected { get; set; }
public override string ToString()
{
if (Selected.HasValue && Selected.Value > 0 && Available != null)
{
var selected = Available.FirstOrDefault(i => i.Value == Selected.ToString());
if (selected != null)
{
return selected.Text;
}
}
else if (Selected.HasValue)
{
return Selected.ToString();
}
return string.Empty;
}
}
}