Routes and controllers gone through
This commit is contained in:
52
Vidly/Controllers/MoviesController.cs
Normal file
52
Vidly/Controllers/MoviesController.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Vidly.Models;
|
||||
|
||||
namespace Vidly.Controllers
|
||||
{
|
||||
public class MoviesController : Controller
|
||||
{
|
||||
// GET: Movies
|
||||
public ActionResult Random()
|
||||
{
|
||||
var movie = new Movie() { Name = "Shrek!" };
|
||||
|
||||
//var viewResult = new ViewResult();
|
||||
//viewResult.ViewData.Model = movie;
|
||||
|
||||
return View(movie);
|
||||
//return Content("Hello World");
|
||||
//return HttpNotFound();
|
||||
//return new EmptyResult();
|
||||
//return RedirectToAction("Index", "Home",new { page = 1, sortBy = "name" });
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ActionResult Edit(int id)
|
||||
{
|
||||
return Content("id=" + id);
|
||||
}
|
||||
|
||||
public ActionResult Index(int? pageIndex, string sortBy)
|
||||
{
|
||||
if (!pageIndex.HasValue)
|
||||
pageIndex = 1;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(sortBy))
|
||||
sortBy = "Name";
|
||||
|
||||
return Content($"pageIndex={pageIndex}&sortBy={sortBy}");
|
||||
}
|
||||
|
||||
[Route("movies/released/{year}/{month:regex(\\d{2}):range(1,12)}")]
|
||||
public ActionResult ByReleaseDate(int year, int month)
|
||||
{
|
||||
return Content(year + "/" + month);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user