Im creating a getting a Location type of application
I am receiving this error
Model item passed into the dictionary is of type 'System.Collections.Generic.List[CA1API.Models.Weather]', but this requires model item type 'System.Collections.Generic.IEnumerable [CA1API.Models.Location]'.
I have created my ViewModel that looks like this namespace CA1API.Models
{
public enum County
{
Ireland,
England,
Iceland
}
public class Location
{
public int LocationID { get; set; }
[Display(Name = "Location")]
public County LocationName { get; set; }
public double Lat { get; set; }
public double Lon { get; set; }
public int WeatherID { get; set; }
public List<Weather> Weathers { get; set; }
}
}
my controller looks like this
public class HomeController : Controller
{
private WeatherDb db = new WeatherDb();
public ActionResult Index()
{
return View(db.Weathers.ToList());
}
}
my view looks like this
@model IEnumerable<CA1API.Models.Location>
<div class="row">
<div class="col-md-2">
<div class="panel panel-success">
<div class="panel-heading">County</div>
<div>
<div class="panel-body" style="overflow-x:hidden; height:300px;">
@foreach (var item in Model)
{
<p>modelItem=>item.County</p>
}
</div>
</div>
</div>
</div>