これを解決するのに苦労しています。インターフェイスを使用してビューモデルを作成するにはどうすればよいですか?
私はいくつかの例をオンラインでフォローしようとしています。
と
http://geekswithblogs.net/michelotti/archive/2009/10/25/asp.net-mvc-view-model-patterns.aspx
しかし、私はそれを機能させることができません。助けていただければ幸いです。これまでの私のコードは以下のとおりです。
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
}
======================アップデート===============
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
}
}