Routes and controllers gone through
This commit is contained in:
@ -23,7 +23,7 @@ namespace Vidly
|
|||||||
"~/Scripts/bootstrap.js"));
|
"~/Scripts/bootstrap.js"));
|
||||||
|
|
||||||
bundles.Add(new StyleBundle("~/Content/css").Include(
|
bundles.Add(new StyleBundle("~/Content/css").Include(
|
||||||
"~/Content/bootstrap.css",
|
"~/Content/bootstrap-lumen.css",
|
||||||
"~/Content/site.css"));
|
"~/Content/site.css"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,14 @@ namespace Vidly
|
|||||||
{
|
{
|
||||||
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
||||||
|
|
||||||
|
routes.MapMvcAttributeRoutes();
|
||||||
|
|
||||||
|
//routes.MapRoute(
|
||||||
|
// "MoviesByReleaseDate",
|
||||||
|
// "movies/released/{year}/{month}",
|
||||||
|
// new {controller = "Movies", action = "ByReleaseDate"},
|
||||||
|
// new { year = @"\d{4}", month = @"\d{2}" });
|
||||||
|
|
||||||
routes.MapRoute(
|
routes.MapRoute(
|
||||||
name: "Default",
|
name: "Default",
|
||||||
url: "{controller}/{action}/{id}",
|
url: "{controller}/{action}/{id}",
|
||||||
|
|||||||
10775
Vidly/Content/bootstrap-lumen.css
vendored
Normal file
10775
Vidly/Content/bootstrap-lumen.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
13
Vidly/Models/Movie.cs
Normal file
13
Vidly/Models/Movie.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace Vidly.Models
|
||||||
|
{
|
||||||
|
public class Movie
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -176,16 +176,19 @@
|
|||||||
<Compile Include="Controllers\AccountController.cs" />
|
<Compile Include="Controllers\AccountController.cs" />
|
||||||
<Compile Include="Controllers\HomeController.cs" />
|
<Compile Include="Controllers\HomeController.cs" />
|
||||||
<Compile Include="Controllers\ManageController.cs" />
|
<Compile Include="Controllers\ManageController.cs" />
|
||||||
|
<Compile Include="Controllers\MoviesController.cs" />
|
||||||
<Compile Include="Global.asax.cs">
|
<Compile Include="Global.asax.cs">
|
||||||
<DependentUpon>Global.asax</DependentUpon>
|
<DependentUpon>Global.asax</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Models\AccountViewModels.cs" />
|
<Compile Include="Models\AccountViewModels.cs" />
|
||||||
<Compile Include="Models\IdentityModels.cs" />
|
<Compile Include="Models\IdentityModels.cs" />
|
||||||
<Compile Include="Models\ManageViewModels.cs" />
|
<Compile Include="Models\ManageViewModels.cs" />
|
||||||
|
<Compile Include="Models\Movie.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Startup.cs" />
|
<Compile Include="Startup.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Content Include="Content\bootstrap-lumen.css" />
|
||||||
<Content Include="Content\bootstrap-theme.css" />
|
<Content Include="Content\bootstrap-theme.css" />
|
||||||
<Content Include="Content\bootstrap-theme.min.css" />
|
<Content Include="Content\bootstrap-theme.min.css" />
|
||||||
<Content Include="Content\bootstrap.css" />
|
<Content Include="Content\bootstrap.css" />
|
||||||
@ -240,6 +243,7 @@
|
|||||||
<Content Include="Views\Manage\VerifyPhoneNumber.cshtml" />
|
<Content Include="Views\Manage\VerifyPhoneNumber.cshtml" />
|
||||||
<Content Include="Views\Shared\Lockout.cshtml" />
|
<Content Include="Views\Shared\Lockout.cshtml" />
|
||||||
<Content Include="Views\Shared\_LoginPartial.cshtml" />
|
<Content Include="Views\Shared\_LoginPartial.cshtml" />
|
||||||
|
<Content Include="Views\Movies\Random.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="App_Data\" />
|
<Folder Include="App_Data\" />
|
||||||
|
|||||||
8
Vidly/Views/Movies/Random.cshtml
Normal file
8
Vidly/Views/Movies/Random.cshtml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
@model Vidly.Models.Movie
|
||||||
|
@{
|
||||||
|
ViewBag.Title = "Random";
|
||||||
|
Layout = "~/Views/Shared/_Layout.cshtml";
|
||||||
|
}
|
||||||
|
|
||||||
|
<h2>@Model.Name</h2>
|
||||||
|
|
||||||
Reference in New Issue
Block a user