6a5b37eda9
Fix for links in the details to the right controller
28 lines
723 B
C#
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;
|
|
}
|
|
}
|
|
} |