Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. public class MoviesController : Controller
  2. {
  3.  
  4. PAPEntities db = new PAPEntities();
  5.  
  6.  
  7. public ActionResult Index()
  8. {
  9.  
  10. MovieViewModel[] movies = db.MoviesData.Select(movie => new MovieViewModel
  11. {
  12. MovieID = movie.MovieID,
  13. MovieName = movie.MovieName,
  14. MovieDescription = movie.MovieDescription,
  15. MovieCategory = movie.MovieCategory,
  16. MovieYear = movie.MovieYear
  17. }).ToArray();
  18.  
  19. return View(movies);
  20.  
  21. }
  22.  
  23. public ActionResult Details(int Id = 1)
  24. {
  25. MovieViewModel MovieVM = db.MoviesData.Find(Id);
  26. return View(MovieVM);
  27. }
  28.  
  29. public class MovieViewModel
  30. {
  31. public int MovieID { get; set; }
  32. public string MovieName { get; set; }
  33. public string MovieDescription { get; set; }
  34. public string MovieCategory { get; set; }
  35. public string MovieYear { get; set; }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement