-1
public ActionResult Index()
{
PAPEntities db = new PAPEntities();
MoviesData movie = db.MoviesData.SingleOrDefault(x => x.MovieID == 1);
List<MovieViewModels> MovieVM = new List<MovieViewModels>
{
new MovieViewModels
{
MovieID = movie.MovieID,
MovieName = movie.MovieName,
MovieDescription = movie.MovieDescription,
MoviePrice = movie.MoviePrice,
MovieCategory = movie.MovieCategory,
MovieYear = movie.MovieYear
}
};
return View(MovieVM);
}
View code
@foreach (var item in Model)
{
<tr>
<td>@item.MovieName</td>
<td>@item.MovieCategory</td>
<td>@item.MovieYear
<td>@item.MoviePrice</td>
</tr>
}
Damn, the code is specifying to get only one record!
– Jéf Bueno
Really? What do I have to change to get all the records?
– Diogo Teixeira
When programming, search and understand what makes each line of your code
– Aesir