I'm having a hard time trying to work this out, how can I create a viewmodel with an interface,
I have been trying to follow a few examples online i.e
and
http://geekswithblogs.net/michelotti/archive/2009/10/25/asp.net-mvc-view-model-patterns.aspx
But I just cannot get it to work, any help would be appreciated, my code so far is below.
public class TravelGuideViewModel
{
private readonly IGetCountryDetails _IGCD;
public DisplayCountryDetails displayCountryDetails { get; set; }
public TravelGuideViewModel(IGetCountryDetails IGCD)
{
_IGCD = IGCD;
}
//Trying to get DisplayCountryDetails here, but everything i try does not work
}
======================Update===============
public class TravelGuideViewModel
{
private readonly IGetCountryDetails _IGCD;
public DisplayCountryDetails displayCountryDetails { get; set; }
public TravelGuideViewModel(IGetCountryDetails IGCD)
{
_IGCD = IGCD;
}
public TravelGuideViewModel Asia()
{
var countries = _IGCD.DisplayCountriesOfTheWorldDetails()
.Where(a => a.strCountryContinent == "Asia").FirstOrDefault();
return countries.strCountry.AsEnumerable(); << Does not work
}
}