47 lines
1.1 KiB
C#
47 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Data.Entity;
|
|
using System.Web.Mvc;
|
|
using Vidly.Models;
|
|
using Vidly.ViewModels;
|
|
|
|
namespace Vidly.Controllers
|
|
{
|
|
public class MoviesController : Controller
|
|
{
|
|
private ApplicationDbContext _context;
|
|
|
|
public MoviesController()
|
|
{
|
|
_context = new ApplicationDbContext();
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
_context.Dispose();
|
|
}
|
|
|
|
[Route("Movies")]
|
|
[Route("Movies/Index")]
|
|
public ActionResult Index()
|
|
{
|
|
var viewModel = new MoviesViewModel()
|
|
{
|
|
Movies = _context.Movies.Include(m => m.MovieGenre).ToList()
|
|
};
|
|
return View(viewModel);
|
|
}
|
|
|
|
[Route("Movies/Movies/{nr}")]
|
|
public ActionResult Movie(int nr)
|
|
{
|
|
var movie = _context.Movies.Include(c => c.MovieGenre).SingleOrDefault(c => c.Id == nr);
|
|
if (movie == null)
|
|
return HttpNotFound();
|
|
return View(movie);
|
|
}
|
|
|
|
}
|
|
} |