The startpage and navigation bars starting to look well
This commit is contained in:
@ -4,6 +4,7 @@ using System.Linq;
|
|||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using Vidly.Models;
|
using Vidly.Models;
|
||||||
|
using Vidly.ViewModels;
|
||||||
|
|
||||||
namespace Vidly.Controllers
|
namespace Vidly.Controllers
|
||||||
{
|
{
|
||||||
@ -13,11 +14,22 @@ namespace Vidly.Controllers
|
|||||||
public ActionResult Random()
|
public ActionResult Random()
|
||||||
{
|
{
|
||||||
var movie = new Movie() { Name = "Shrek!" };
|
var movie = new Movie() { Name = "Shrek!" };
|
||||||
|
var customers = new List<Customer>
|
||||||
|
{
|
||||||
|
new Customer {Name="Customer 1"},
|
||||||
|
new Customer {Name="Customer 2"}
|
||||||
|
};
|
||||||
//var viewResult = new ViewResult();
|
//var viewResult = new ViewResult();
|
||||||
//viewResult.ViewData.Model = movie;
|
//viewResult.ViewData.Model = movie;
|
||||||
|
|
||||||
return View(movie);
|
var viewModel = new RandomMovieViewModel() {
|
||||||
|
Movie = movie,
|
||||||
|
Customers = customers
|
||||||
|
};
|
||||||
|
|
||||||
|
return View(viewModel);
|
||||||
|
|
||||||
|
//return View(movie);
|
||||||
//return Content("Hello World");
|
//return Content("Hello World");
|
||||||
//return HttpNotFound();
|
//return HttpNotFound();
|
||||||
//return new EmptyResult();
|
//return new EmptyResult();
|
||||||
|
|||||||
14
Vidly/Models/Customer.cs
Normal file
14
Vidly/Models/Customer.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace Vidly.Models
|
||||||
|
{
|
||||||
|
public class Customer
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -181,11 +181,13 @@
|
|||||||
<DependentUpon>Global.asax</DependentUpon>
|
<DependentUpon>Global.asax</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Models\AccountViewModels.cs" />
|
<Compile Include="Models\AccountViewModels.cs" />
|
||||||
|
<Compile Include="Models\Customer.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="Models\Movie.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Startup.cs" />
|
<Compile Include="Startup.cs" />
|
||||||
|
<Compile Include="ViewModels\RandomMovieViewModel.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Content\bootstrap-lumen.css" />
|
<Content Include="Content\bootstrap-lumen.css" />
|
||||||
@ -244,6 +246,7 @@
|
|||||||
<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" />
|
<Content Include="Views\Movies\Random.cshtml" />
|
||||||
|
<Content Include="Views\Shared\_NavBar.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="App_Data\" />
|
<Folder Include="App_Data\" />
|
||||||
|
|||||||
14
Vidly/ViewModels/RandomMovieViewModel.cs
Normal file
14
Vidly/ViewModels/RandomMovieViewModel.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
using Vidly.Models;
|
||||||
|
|
||||||
|
namespace Vidly.ViewModels
|
||||||
|
{
|
||||||
|
public class RandomMovieViewModel
|
||||||
|
{
|
||||||
|
public Movie Movie { get; set; }
|
||||||
|
public List<Customer> Customers { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,8 +1,33 @@
|
|||||||
@model Vidly.Models.Movie
|
@model Vidly.ViewModels.RandomMovieViewModel
|
||||||
@{
|
@{
|
||||||
ViewBag.Title = "Random";
|
ViewBag.Title = "Random";
|
||||||
Layout = "~/Views/Shared/_Layout.cshtml";
|
Layout = "~/Views/Shared/_Layout.cshtml";
|
||||||
}
|
}
|
||||||
|
|
||||||
<h2>@Model.Name</h2>
|
@**
|
||||||
|
This is a comment
|
||||||
|
on multiple lines
|
||||||
|
*@
|
||||||
|
|
||||||
|
@{
|
||||||
|
var className = Model.Customers.Count > 0 ? "popular" : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
<h2 class="@className">@Model.Movie.Name</h2>
|
||||||
|
|
||||||
|
@if (Model.Customers.Count == 0)
|
||||||
|
{
|
||||||
|
<text>No one has rented this movie before.</text>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<ul>
|
||||||
|
@foreach (var customer in Model.Customers)
|
||||||
|
{
|
||||||
|
<li>@customer.Name</li>
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,31 +4,13 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>@ViewBag.Title - My ASP.NET Application</title>
|
<title>@ViewBag.Title - My ASP.NET Application</title>
|
||||||
|
|
||||||
@Styles.Render("~/Content/css")
|
@Styles.Render("~/Content/css")
|
||||||
@Scripts.Render("~/bundles/modernizr")
|
@Scripts.Render("~/bundles/modernizr")
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
@Html.Partial("_NavBar")
|
||||||
<div class="container">
|
|
||||||
<div class="navbar-header">
|
|
||||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
|
||||||
<span class="icon-bar"></span>
|
|
||||||
<span class="icon-bar"></span>
|
|
||||||
<span class="icon-bar"></span>
|
|
||||||
</button>
|
|
||||||
@Html.ActionLink("Application name", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
|
|
||||||
</div>
|
|
||||||
<div class="navbar-collapse collapse">
|
|
||||||
<ul class="nav navbar-nav">
|
|
||||||
<li>@Html.ActionLink("Home", "Index", "Home")</li>
|
|
||||||
<li>@Html.ActionLink("About", "About", "Home")</li>
|
|
||||||
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>
|
|
||||||
</ul>
|
|
||||||
@Html.Partial("_LoginPartial")
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="container body-content">
|
<div class="container body-content">
|
||||||
@RenderBody()
|
@RenderBody()
|
||||||
<hr />
|
<hr />
|
||||||
|
|||||||
@ -4,19 +4,16 @@
|
|||||||
using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))
|
using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))
|
||||||
{
|
{
|
||||||
@Html.AntiForgeryToken()
|
@Html.AntiForgeryToken()
|
||||||
|
<ul class="nav navbar-nav navbar-right mr-auto">
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<li class="nav-item">@Html.ActionLink("Hello " + User.Identity.GetUserName() + "!", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })</li>
|
||||||
<li>
|
<li class="nav-item"><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li>
|
||||||
@Html.ActionLink("Hello " + User.Identity.GetUserName() + "!", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })
|
|
||||||
</li>
|
|
||||||
<li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right mr-auto">
|
||||||
<li>@Html.ActionLink("Register", "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" })</li>
|
<li class="nav-item">@Html.ActionLink("Register", "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink", @class = "nav-link" })</li>
|
||||||
<li>@Html.ActionLink("Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" })</li>
|
<li class="nav-item">@Html.ActionLink("Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink", @class = "nav-link" })</li>
|
||||||
</ul>
|
</ul>
|
||||||
}
|
}
|
||||||
|
|||||||
19
Vidly/Views/Shared/_NavBar.cshtml
Normal file
19
Vidly/Views/Shared/_NavBar.cshtml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
|
||||||
|
<nav class="navbar navbar-expand-sm navbar-dark fixed-top bg-dark">
|
||||||
|
<div class="container">
|
||||||
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
@Html.ActionLink("My Web Portal", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
|
||||||
|
<div class="navbar-collapse collapse" id="navbarSupportedContent">
|
||||||
|
|
||||||
|
<ul class="nav navbar-nav mr-auto">
|
||||||
|
<li class="nav-item">@Html.ActionLink("Home", "Index", "Home", null, new { @class = "nav-link" })</li>
|
||||||
|
<li class="nav-item">@Html.ActionLink("About", "About", "Home", null, new { @class = "nav-link" })</li>
|
||||||
|
<li class="nav-item">@Html.ActionLink("Contact", "Contact", "Home", null, new { @class = "nav-link" })</li>
|
||||||
|
</ul>
|
||||||
|
@Html.Partial("_LoginPartial")
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
Reference in New Issue
Block a user