Tag helpers

This commit is contained in:
Praburaj 2015-04-02 12:07:25 -07:00
parent 035c97a7bf
commit ba80195851
49 changed files with 296 additions and 311 deletions

View File

@ -13,6 +13,7 @@
<PropertyGroup> <PropertyGroup>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<DevelopmentServerPort>1575</DevelopmentServerPort> <DevelopmentServerPort>1575</DevelopmentServerPort>
<GruntGulpQueried>True</GruntGulpQueried>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" /> <Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project> </Project>

View File

@ -1,6 +1,5 @@
using System.Linq; using System.Linq;
using System.Security.Claims; using System.Security.Claims;
using System.Security.Principal;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Authorization; using Microsoft.AspNet.Authorization;
using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Hosting;

View File

@ -33,8 +33,6 @@ namespace MusicStore.Controllers
return View(albums); return View(albums);
} }
//Can be removed and handled when HandleError filter is implemented
//https://github.com/aspnet/Mvc/issues/623
public IActionResult Error() public IActionResult Error()
{ {
return View("~/Views/Shared/Error.cshtml"); return View("~/Views/Shared/Error.cshtml");

View File

@ -0,0 +1,7 @@
namespace MusicStore
{
public class AppSettings
{
public string SiteTitle { get; set; }
}
}

View File

@ -1,8 +1,8 @@
/// <autosync enabled="true" /> /// <autosync enabled="true" />
/// <reference path="../wwwroot/Scripts/bootstrap.js" />
/// <reference path="../wwwroot/Scripts/jquery-2.0.3.js" />
/// <reference path="../wwwroot/Scripts/jquery.signalR-2.0.1.js" />
/// <reference path="../wwwroot/Scripts/jquery.validate.js" />
/// <reference path="../wwwroot/Scripts/jquery.validate.unobtrusive.js" />
/// <reference path="../wwwroot/Scripts/modernizr-2.6.2.js" />
/// <reference path="../wwwroot/Scripts/respond.js" /> /// <reference path="../wwwroot/Scripts/respond.js" />
/// <reference path="../wwwroot/Scripts/modernizr-2.6.2.js" />
/// <reference path="../wwwroot/Scripts/jquery.validate.unobtrusive.js" />
/// <reference path="../wwwroot/Scripts/jquery.validate.js" />
/// <reference path="../wwwroot/Scripts/jquery.signalR-2.0.1.js" />
/// <reference path="../wwwroot/Scripts/jquery-2.0.3.js" />
/// <reference path="../wwwroot/Scripts/bootstrap.js" />

View File

@ -28,6 +28,8 @@ namespace MusicStore
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.Configure<AppSettings>(Configuration.GetSubKey("AppSettings"));
//Sql client not available on mono //Sql client not available on mono
var useInMemoryStore = Type.GetType("Mono.Runtime") != null; var useInMemoryStore = Type.GetType("Mono.Runtime") != null;

View File

@ -43,6 +43,8 @@ namespace MusicStore
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.Configure<AppSettings>(Configuration.GetSubKey("AppSettings"));
// Add EF services to the services container // Add EF services to the services container
services.AddEntityFramework() services.AddEntityFramework()
.AddSqlServer() .AddSqlServer()

View File

@ -41,6 +41,8 @@ namespace MusicStore
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.Configure<AppSettings>(Configuration.GetSubKey("AppSettings"));
//Sql client not available on mono //Sql client not available on mono
var useInMemoryStore = Type.GetType("Mono.Runtime") != null; var useInMemoryStore = Type.GetType("Mono.Runtime") != null;

View File

@ -5,6 +5,6 @@
<h2>@ViewBag.Title.</h2> <h2>@ViewBag.Title.</h2>
<div> <div>
<p> <p>
Thank you for confirming your email. Please @Html.ActionLink("Click here to Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" }) Thank you for confirming your email. Please <a asp-controller="Account" asp-action="Login">Click here to Log in</a>.
</p> </p>
</div> </div>

View File

@ -1,27 +1,25 @@
@model MusicStore.Models.ExternalLoginConfirmationViewModel @model ExternalLoginConfirmationViewModel
@{ @{
ViewBag.Title = "Register"; ViewBag.Title = "Register";
} }
<h2>@ViewBag.Title.</h2> <h2>@ViewBag.Title.</h2>
<h3>Associate your @ViewBag.LoginProvider account.</h3> <h3>Associate your @ViewBag.LoginProvider account.</h3>
@using (Html.BeginForm("ExternalLoginConfirmation", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" })) <form asp-controller="Account" asp-action="ExternalLoginConfirmation" asp-route-returnurl="@ViewBag.ReturnUrl" method="post" class="form-horizontal" role="form">
{
@Html.AntiForgeryToken()
<h4>Association Form</h4> <h4>Association Form</h4>
<hr /> <hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" }) <div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
<p class="text-info"> <p class="text-info">
You've successfully authenticated with <strong>@ViewBag.LoginProvider</strong>. You've successfully authenticated with <strong>@ViewBag.LoginProvider</strong>.
Please enter a user name for this site below and click the Register button to finish Please enter a user name for this site below and click the Register button to finish
logging in. logging in.
</p> </p>
<div class="form-group"> <div class="form-group">
@Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" }) <label asp-for="Email" class="col-md-2 control-label"></label>
<div class="col-md-10"> <div class="col-md-10">
@Html.TextBoxFor(m => m.Email, new { @class = "form-control" }) <input asp-for="Email" class="form-control" />
@Html.ValidationMessageFor(m => m.Email, "", new { @class = "text-danger" }) <span asp-validation-for="Email" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -29,11 +27,8 @@
<input type="submit" class="btn btn-default" value="Register" /> <input type="submit" class="btn btn-default" value="Register" />
</div> </div>
</div> </div>
} </form>
@section Scripts { @section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@ @{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
@*@Scripts.Render("~/bundles/jqueryval")*@
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
} }

View File

@ -5,4 +5,4 @@
<hgroup> <hgroup>
<h2>@ViewBag.Title.</h2> <h2>@ViewBag.Title.</h2>
<h3 class="text-danger">Unsuccessful login with service.</h3> <h3 class="text-danger">Unsuccessful login with service.</h3>
</hgroup> </hgroup>

View File

@ -1,20 +1,19 @@
@model MusicStore.Models.ForgotPasswordViewModel @model ForgotPasswordViewModel
@{ @{
ViewBag.Title = "Forgot your password?"; ViewBag.Title = "Forgot your password?";
} }
<h2>@ViewBag.Title.</h2> <h2>@ViewBag.Title.</h2>
@using (Html.BeginForm("ForgotPassword", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" })) <form asp-controller="Account" asp-action="ForgotPassword" method="post" class="form-horizontal" role="form">
{
@Html.AntiForgeryToken()
<h4>Enter your email.</h4> <h4>Enter your email.</h4>
<hr /> <hr />
@Html.ValidationSummary("", new { @class = "text-danger" }) <div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
<div class="form-group"> <div class="form-group">
@Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" }) <label asp-for="Email" class="col-md-2 control-label"></label>
<div class="col-md-10"> <div class="col-md-10">
@Html.TextBoxFor(m => m.Email, new { @class = "form-control" }) <input asp-for="Email" class="form-control" />
<span asp-validation-for="Email" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -22,11 +21,8 @@
<input type="submit" class="btn btn-default" value="Email Link" /> <input type="submit" class="btn btn-default" value="Email Link" />
</div> </div>
</div> </div>
} </form>
@section Scripts { @section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@ @{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
@*@Scripts.Render("~/bundles/jqueryval")*@
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
} }

View File

@ -10,6 +10,6 @@
Please check your email to reset your password. Please check your email to reset your password.
</p> </p>
<p> <p>
For demo purpose only: @Html.ActionLink("Click here to reset the password: ", "ResetPassword", new { code = ViewBag.Code }); For demo purpose only: <a asp-action="ResetPassword" asp-route-code="@ViewBag.Code">Click here to reset the password</a>
</p> </p>
</div> </div>

View File

@ -1,5 +1,4 @@
@using MusicStore.Models @model LoginViewModel
@model LoginViewModel
@{ @{
ViewBag.Title = "Log in"; ViewBag.Title = "Log in";
@ -9,31 +8,29 @@
<div class="row"> <div class="row">
<div class="col-md-8"> <div class="col-md-8">
<section id="loginForm"> <section id="loginForm">
@using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" })) <form asp-controller="Account" asp-action="Login" asp-route-returnurl="@ViewBag.ReturnUrl" method="post" class="form-horizontal" role="form">
{
@Html.AntiForgeryToken()
<h4>Use a local account to log in.</h4> <h4>Use a local account to log in.</h4>
<hr /> <hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" }) <div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
<div class="form-group"> <div class="form-group">
@Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" }) <label asp-for="Email" class="col-md-2 control-label"></label>
<div class="col-md-10"> <div class="col-md-10">
@Html.TextBoxFor(m => m.Email, new { @class = "form-control" }) <input asp-for="Email" class="form-control" />
@Html.ValidationMessageFor(m => m.Email, "", new { @class = "text-danger" }) <span asp-validation-for="Email" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@Html.LabelFor(m => m.Password, new { @class = "col-md-2 control-label" }) <label asp-for="Password" class="col-md-2 control-label"></label>
<div class="col-md-10"> <div class="col-md-10">
@Html.PasswordFor(m => m.Password, new { @class = "form-control" }) <input asp-for="Password" class="form-control" />
@Html.ValidationMessageFor(m => m.Password, "", new { @class = "text-danger" }) <span asp-validation-for="Password" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-md-offset-2 col-md-10"> <div class="col-md-offset-2 col-md-10">
<div class="checkbox"> <div class="checkbox">
@Html.CheckBoxFor(m => m.RememberMe) <input asp-for="RememberMe" />
@Html.LabelFor(m => m.RememberMe) <label asp-for="RememberMe"></label>
</div> </div>
</div> </div>
</div> </div>
@ -43,13 +40,12 @@
</div> </div>
</div> </div>
<p> <p>
@Html.ActionLink("Register as a new user", "Register") <a asp-action="Register">Register as a new user?</a>
</p> </p>
@*Enable this once you have account confirmation enabled for password reset functionality*@
<p> <p>
@Html.ActionLink("Forgot your password?", "ForgotPassword") <a asp-action="ForgotPassword">Forgot your password?</a>
</p> </p>
} </form>
</section> </section>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
@ -58,9 +54,7 @@
</section> </section>
</div> </div>
</div> </div>
@section Scripts { @section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@ @{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
@*@Scripts.Render("~/bundles/jqueryval")*@
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
} }

View File

@ -1,32 +1,33 @@
@model MusicStore.Models.RegisterViewModel @model RegisterViewModel
@{ @{
ViewBag.Title = "Register"; ViewBag.Title = "Register";
} }
<h2>@ViewBag.Title.</h2> <h2>@ViewBag.Title.</h2>
@using (Html.BeginForm("Register", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" })) <form asp-controller="Account" asp-action="Register" method="post" class="form-horizontal" role="form">
{
@Html.AntiForgeryToken()
<h4>Create a new account.</h4> <h4>Create a new account.</h4>
<hr /> <hr />
@Html.ValidationSummary("", new { @class = "text-danger" }) <div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
<div class="form-group"> <div class="form-group">
@Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" }) <label asp-for="Email" class="col-md-2 control-label"></label>
<div class="col-md-10"> <div class="col-md-10">
@Html.TextBoxFor(m => m.Email, new { @class = "form-control" }) <input asp-for="Email" class="form-control" />
<span asp-validation-for="Email" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@Html.LabelFor(m => m.Password, new { @class = "col-md-2 control-label" }) <label asp-for="Password" class="col-md-2 control-label"></label>
<div class="col-md-10"> <div class="col-md-10">
@Html.PasswordFor(m => m.Password, new { @class = "form-control" }) <input asp-for="Password" class="form-control" />
<span asp-validation-for="Password" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@Html.LabelFor(m => m.ConfirmPassword, new { @class = "col-md-2 control-label" }) <label asp-for="ConfirmPassword" class="col-md-2 control-label"></label>
<div class="col-md-10"> <div class="col-md-10">
@Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control" }) <input asp-for="ConfirmPassword" class="form-control" />
<span asp-validation-for="ConfirmPassword" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -34,11 +35,8 @@
<input type="submit" class="btn btn-default" value="Register" /> <input type="submit" class="btn btn-default" value="Register" />
</div> </div>
</div> </div>
} </form>
@section Scripts { @section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@ @{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
@*@Scripts.Render("~/bundles/jqueryval")*@
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
} }

View File

@ -10,6 +10,6 @@
Please check your email to activate your account. Please check your email to activate your account.
</p> </p>
<p> <p>
Demo/testing purposes only: The sample displays the code and user id in the page: @Html.ActionLink("Click here to confirm your email: ", "ConfirmEmail", new { code = ViewBag.Code, userId = ViewBag.UserId }) Demo/testing purposes only: The sample displays the code and user id in the page: <a asp-action="ConfirmEmail" asp-route-code="@ViewBag.Code" asp-route-userId="@ViewBag.UserId">Click here to confirm your email: </a>
</p> </p>
</div> </div>

View File

@ -1,33 +1,34 @@
@model MusicStore.Models.ResetPasswordViewModel @model ResetPasswordViewModel
@{ @{
ViewBag.Title = "Reset password"; ViewBag.Title = "Reset password";
} }
<h2>@ViewBag.Title.</h2> <h2>@ViewBag.Title.</h2>
@using (Html.BeginForm("ResetPassword", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" })) <form asp-controller="Account" asp-action="ResetPassword" method="post" class="form-horizontal" role="form">
{
@Html.AntiForgeryToken()
<h4>Reset your password.</h4> <h4>Reset your password.</h4>
<hr /> <hr />
@Html.ValidationSummary("", new { @class = "text-danger" }) <div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
@Html.HiddenFor(model => model.Code) <input asp-for="Code" type="hidden" />
<div class="form-group"> <div class="form-group">
@Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" }) <label asp-for="Email" class="col-md-2 control-label"></label>
<div class="col-md-10"> <div class="col-md-10">
@Html.TextBoxFor(m => m.Email, new { @class = "form-control" }) <input asp-for="Email" class="form-control" />
<span asp-validation-for="Email" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@Html.LabelFor(m => m.Password, new { @class = "col-md-2 control-label" }) <label asp-for="Password" class="col-md-2 control-label"></label>
<div class="col-md-10"> <div class="col-md-10">
@Html.PasswordFor(m => m.Password, new { @class = "form-control" }) <input asp-for="Password" class="form-control" />
<span asp-validation-for="Password" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@Html.LabelFor(m => m.ConfirmPassword, new { @class = "col-md-2 control-label" }) <label asp-for="ConfirmPassword" class="col-md-2 control-label"></label>
<div class="col-md-10"> <div class="col-md-10">
@Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control" }) <input asp-for="ConfirmPassword" class="form-control" />
<span asp-validation-for="ConfirmPassword" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -35,11 +36,8 @@
<input type="submit" class="btn btn-default" value="Reset" /> <input type="submit" class="btn btn-default" value="Reset" />
</div> </div>
</div> </div>
} </form>
@section Scripts { @section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@ @{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
@*@Scripts.Render("~/bundles/jqueryval")*@
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
} }

View File

@ -7,6 +7,6 @@
</hgroup> </hgroup>
<div> <div>
<p> <p>
Your password has been reset. Please @Html.ActionLink("click here to log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" }) Your password has been reset. Please <a asp-controller="Account" asp-action="Login">Click here to log in</a>.
</p> </p>
</div> </div>

View File

@ -1,28 +1,21 @@
@model MusicStore.Models.SendCodeViewModel @model SendCodeViewModel
@{ @{
ViewBag.Title = "Send"; ViewBag.Title = "Send Verification Code";
} }
<h2>@ViewBag.Title.</h2> <h2>@ViewBag.Title.</h2>
@using (Html.BeginForm("SendCode", "Account", new { ReturnUrl = Model.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" })) <form asp-controller="Account" asp-action="SendCode" asp-route-returnurl="@Model.ReturnUrl" method="post" class="form-horizontal" role="form">
{ <input asp-for="RememberMe" type="hidden" />
@Html.AntiForgeryToken()
@Html.Hidden("rememberMe", @Model.RememberMe)
<h4>Send verification code</h4>
<hr />
<div class="row"> <div class="row">
<div class="col-md-8"> <div class="col-md-8">
Select Two-Factor Authentication Provider: Select Two-Factor Authentication Provider:
@Html.DropDownListFor(model => model.SelectedProvider, Model.Providers) <select asp-for="SelectedProvider" asp-items="Model.Providers"></select>
<input type="submit" value="Submit" class="btn btn-default" /> <input type="submit" value="Submit" class="btn btn-default" />
</div> </div>
</div> </div>
} </form>
@section Scripts { @section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@ @{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
@*@Scripts.Render("~/bundles/jqueryval")*@ }
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
}

View File

@ -1,15 +1,14 @@
@model MusicStore.Models.VerifyCodeViewModel @model VerifyCodeViewModel
@{ @{
ViewBag.Title = "Verify"; ViewBag.Title = "Verify";
} }
<h2>@ViewBag.Title.</h2> <h2>@ViewBag.Title.</h2>
@using (Html.BeginForm("VerifyCode", "Account", new { ReturnUrl = Model.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" })) <form asp-controller="Account" asp-action="VerifyCode" asp-route-returnurl="@Model.ReturnUrl" method="post" class="form-horizontal" role="form">
{ <div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
@Html.AntiForgeryToken() <input asp-for="Provider" type="hidden" />
@Html.Hidden("provider", @Model.Provider) <input asp-for="RememberMe" type="hidden" />
@Html.Hidden("rememberMe", @Model.RememberMe)
<h4>Enter verification code</h4> <h4>Enter verification code</h4>
<p class="text-danger"> <p class="text-danger">
For DEMO only: You can type in this code in the below text box to proceed: [ @ViewBag.Code ] For DEMO only: You can type in this code in the below text box to proceed: [ @ViewBag.Code ]
@ -17,18 +16,18 @@
Please change this code to register an SMS/Email service in IdentityConfig to send a message. Please change this code to register an SMS/Email service in IdentityConfig to send a message.
</p> </p>
<hr /> <hr />
@Html.ValidationSummary("", new { @class = "text-danger" })
<div class="form-group"> <div class="form-group">
@Html.LabelFor(m => m.Code, new { @class = "col-md-2 control-label" }) <label asp-for="Code" class="col-md-2 control-label"></label>
<div class="col-md-10"> <div class="col-md-10">
@Html.TextBoxFor(m => m.Code, new { @class = "form-control" }) <input asp-for="Code" class="form-control" />
<span asp-validation-for="Code" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-md-offset-2 col-md-10"> <div class="col-md-offset-2 col-md-10">
<div class="checkbox"> <div class="checkbox">
@Html.CheckBoxFor(m => m.RememberBrowser) <input asp-for="RememberBrowser" />
@Html.LabelFor(m => m.RememberBrowser) <label asp-for="RememberBrowser"></label>
</div> </div>
</div> </div>
</div> </div>
@ -37,11 +36,8 @@
<input type="submit" class="btn btn-default" value="Submit" /> <input type="submit" class="btn btn-default" value="Submit" />
</div> </div>
</div> </div>
} </form>
@section Scripts { @section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@ @{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
@*@Scripts.Render("~/bundles/jqueryval")*@ }
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
}

View File

@ -1,6 +1,4 @@
@using MusicStore.Models; @using Microsoft.AspNet.Http.Authentication;
@using Microsoft.AspNet.Http.Authentication;
@using Microsoft.AspNet.Identity;
@model ExternalLoginListViewModel @model ExternalLoginListViewModel
@inject SignInManager<ApplicationUser> SignInManager @inject SignInManager<ApplicationUser> SignInManager
<h4>Use another service to log in.</h4> <h4>Use another service to log in.</h4>
@ -18,17 +16,15 @@
} }
else else
{ {
using (Html.BeginForm("ExternalLogin", "Account", new { ReturnUrl = Model.ReturnUrl })) <form asp-controller="Account" asp-action="ExternalLogin" asp-route-returnurl="@ViewBag.ReturnUrl" method="post" class="form-horizontal" role="form">
{
@Html.AntiForgeryToken()
<div id="socialLoginList"> <div id="socialLoginList">
<p> <p>
@foreach (AuthenticationDescription p in loginProviders.Where(a => a.Caption != null)) @foreach (AuthenticationDescription p in loginProviders)
{ {
<button type="submit" class="btn btn-default" id="@p.AuthenticationScheme" name="provider" value="@p.AuthenticationScheme" title="Log in using your @p.Caption account">@p.AuthenticationScheme</button> <button type="submit" class="btn btn-default" id="@p.AuthenticationScheme" name="provider" value="@p.AuthenticationScheme" title="Log in using your @p.Caption account">@p.AuthenticationScheme</button>
} }
</p> </p>
</div> </div>
} </form>
} }
} }

View File

@ -1,22 +1,17 @@
@model MusicStore.Models.Order @model Order
@{ @{
ViewBag.Title = "Address And Payment"; ViewBag.Title = "Address And Payment";
} }
@section Scripts { @section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@ @{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
@*@Scripts.Render("~/bundles/jqueryval")*@
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
} }
@using (Html.BeginForm()) <form>
{
@Html.AntiForgeryToken()
<h2>Address And Payment</h2> <h2>Address And Payment</h2>
<hr /> <hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" }) <div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
<fieldset> <fieldset>
<legend>Shipping Information</legend> <legend>Shipping Information</legend>
@ -27,7 +22,7 @@
<p>We're running a promotion: all music is free with the promo code: "FREE"</p> <p>We're running a promotion: all music is free with the promo code: "FREE"</p>
<div class="editor-label"> <div class="editor-label">
@Html.Label("Promo Code") <label title="Promo Code">Promo Code</label>
</div> </div>
<div class="editor-field"> <div class="editor-field">
@Html.TextBox("PromoCode") @Html.TextBox("PromoCode")
@ -35,4 +30,4 @@
</fieldset> </fieldset>
<input type="submit" value="Submit Order" /> <input type="submit" value="Submit Order" />
} </form>

View File

@ -10,5 +10,5 @@
<p> <p>
How about shopping for some more music in our How about shopping for some more music in our
@Html.ActionLink("Store", "Index", "Home") <a asp-controller="Home" asp-action="Index">Store</a>
</p> </p>

View File

@ -1,20 +1,21 @@
@{ @inject IOptions<AppSettings> AppSettings
@{
ViewBag.Title = "Home Page"; ViewBag.Title = "Home Page";
} }
<div class="jumbotron"> <div class="jumbotron">
<h1>MVC Music Store</h1> <h1>@AppSettings.Options.SiteTitle</h1>
<img src="~/Images/home-showcase.png" /> <img src="~/Images/home-showcase.png" />
</div> </div>
<ul class="row list-unstyled" id="album-list"> <ul class="row list-unstyled" id="album-list">
@foreach (var album in Model) @foreach (var album in Model)
{ {
<li class="col-lg-2 col-md-2 col-sm-2 col-xs-4 container"> <li class="col-lg-2 col-md-2 col-sm-2 col-xs-4 container">
<a href="@Url.Action("Details", "Store", new { id = album.AlbumId })"> <a asp-controller="Store" asp-action="Details" asp-route-id="@album.AlbumId">
<img alt="@album.Title" src="@Url.Content(@album.AlbumArtUrl)" /> <img alt="@album.Title" src="@Url.Content(@album.AlbumArtUrl)" />
<h4>@album.Title</h4> <h4>@album.Title</h4>
</a> </a>
</li> </li>
} }
</ul> </ul>

View File

@ -1,32 +1,27 @@
@model MusicStore.Models.AddPhoneNumberViewModel @model AddPhoneNumberViewModel
@{ @{
ViewBag.Title = "Phone Number"; ViewBag.Title = "Add Phone Number";
} }
<h2>@ViewBag.Title.</h2> <h2>@ViewBag.Title.</h2>
<form asp-controller="Manage" asp-action="AddPhoneNumber" method="post" class="form-horizontal" role="form">
@using (Html.BeginForm("AddPhoneNumber", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" })) <h4>Add a phone number.</h4>
{
@Html.AntiForgeryToken()
<h4>Add a phone number</h4>
<hr /> <hr />
@Html.ValidationSummary("", new { @class = "text-danger" }) <div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
<div class="form-group"> <div class="form-group">
@Html.LabelFor(m => m.Number, new { @class = "col-md-2 control-label" }) <label asp-for="Number" class="col-md-2 control-label"></label>
<div class="col-md-10"> <div class="col-md-10">
@Html.TextBoxFor(m => m.Number, new { @class = "form-control" }) <input asp-for="Number" class="form-control" />
<span asp-validation-for="Number" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-md-offset-2 col-md-10"> <div class="col-md-offset-2 col-md-10">
<input type="submit" class="btn btn-default" value="Submit" /> <input type="submit" class="btn btn-default" value="Send verification code" />
</div> </div>
</div> </div>
} </form>
@section Scripts { @section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@ @{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
@*@Scripts.Render("~/bundles/jqueryval")*@
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
} }

View File

@ -1,32 +1,33 @@
@model MusicStore.Models.ChangePasswordViewModel @model ChangePasswordViewModel
@{ @{
ViewBag.Title = "Change Password"; ViewBag.Title = "Change Password";
} }
<h2>@ViewBag.Title.</h2> <h2>@ViewBag.Title.</h2>
@using (Html.BeginForm("ChangePassword", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" })) <form asp-controller="Manage" asp-action="ChangePassword" method="post" class="form-horizontal" role="form">
{
@Html.AntiForgeryToken()
<h4>Change Password Form</h4> <h4>Change Password Form</h4>
<hr /> <hr />
@Html.ValidationSummary("", new { @class = "text-danger" }) <div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
<div class="form-group"> <div class="form-group">
@Html.LabelFor(m => m.OldPassword, new { @class = "col-md-2 control-label" }) <label asp-for="OldPassword" class="col-md-2 control-label"></label>
<div class="col-md-10"> <div class="col-md-10">
@Html.PasswordFor(m => m.OldPassword, new { @class = "form-control" }) <input asp-for="OldPassword" class="form-control" />
<span asp-validation-for="OldPassword" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@Html.LabelFor(m => m.NewPassword, new { @class = "col-md-2 control-label" }) <label asp-for="NewPassword" class="col-md-2 control-label"></label>
<div class="col-md-10"> <div class="col-md-10">
@Html.PasswordFor(m => m.NewPassword, new { @class = "form-control" }) <input asp-for="NewPassword" class="form-control" />
<span asp-validation-for="NewPassword" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@Html.LabelFor(m => m.ConfirmPassword, new { @class = "col-md-2 control-label" }) <label asp-for="ConfirmPassword" class="col-md-2 control-label"></label>
<div class="col-md-10"> <div class="col-md-10">
@Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control" }) <input asp-for="ConfirmPassword" class="form-control" />
<span asp-validation-for="ConfirmPassword" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -34,10 +35,8 @@
<input type="submit" value="Change password" class="btn btn-default" /> <input type="submit" value="Change password" class="btn btn-default" />
</div> </div>
</div> </div>
} </form>
@section Scripts { @section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@ @{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
@*@Scripts.Render("~/bundles/jqueryval")*@ }
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
}

View File

@ -1,6 +1,6 @@
@model MusicStore.Models.IndexViewModel @model IndexViewModel
@{ @{
ViewBag.Title = "Manage"; ViewBag.Title = "Manage your account";
} }
<h2>@ViewBag.Title.</h2> <h2>@ViewBag.Title.</h2>
@ -15,18 +15,17 @@
[ [
@if (Model.HasPassword) @if (Model.HasPassword)
{ {
@Html.ActionLink("Change your password", "ChangePassword") <a asp-controller="Manage" asp-action="ChangePassword">Change</a>
} }
else else
{ {
@Html.ActionLink("Create", "SetPassword") <a asp-controller="Manage" asp-action="SetPassword">Create</a>
} }
] ]
</dd> </dd>
<dt>External Logins:</dt> <dt>External Logins:</dt>
<dd> <dd>
@Model.Logins.Count [ @Model.Logins.Count [<a asp-controller="Manage" asp-action="ManageLogins">Manage</a>]
@Html.ActionLink("Manage", "ManageLogins") ]
</dd> </dd>
@* @*
Phone Numbers can used as a second factor of verification in a two-factor authentication system. Phone Numbers can used as a second factor of verification in a two-factor authentication system.
@ -42,13 +41,13 @@
@(Model.PhoneNumber ?? "None") [ @(Model.PhoneNumber ?? "None") [
@if (Model.PhoneNumber != null) @if (Model.PhoneNumber != null)
{ {
@Html.ActionLink("Change", "AddPhoneNumber") <a asp-controller="Manage" asp-action="AddPhoneNumber">Change</a>
@: &nbsp;|&nbsp; @: &nbsp;|&nbsp;
@Html.ActionLink("Remove", "RemovePhoneNumber") <a asp-controller="Manage" asp-action="RemovePhoneNumber">Remove</a>
} }
else else
{ {
@Html.ActionLink("Add", "AddPhoneNumber") <a asp-controller="Manage" asp-action="AddPhoneNumber">Add</a>
} }
] ]
</dd> </dd>
@ -56,51 +55,43 @@
<dd> <dd>
@if (Model.TwoFactor) @if (Model.TwoFactor)
{ {
using (Html.BeginForm("DisableTwoFactorAuthentication", "Manage", FormMethod.Post)) <form asp-controller="Manage" asp-action="DisableTwoFactorAuthentication" method="post" class="form-horizontal" role="form">
{
@Html.AntiForgeryToken()
<p> <p>
Enabled Enabled
<input type="submit" value="Disable" class="btn btn-link" /> <input type="submit" value="Disable" class="btn btn-link" />
</p> </p>
} </form>
} }
else else
{ {
using (Html.BeginForm("EnableTwoFactorAuthentication", "Manage", FormMethod.Post)) <form asp-controller="Manage" asp-action="EnableTwoFactorAuthentication" method="post" class="form-horizontal" role="form">
{
@Html.AntiForgeryToken()
<p> <p>
Disabled Disabled
<input type="submit" value="Enable" class="btn btn-link" /> <input type="submit" value="Enable" class="btn btn-link" />
</p> </p>
} </form>
} }
</dd> </dd>
<dt>Browser remembered:</dt> <dt>Browser remembered:</dt>
<dd> <dd>
@if (Model.BrowserRemembered) @if (Model.BrowserRemembered)
{ {
using (Html.BeginForm("ForgetBrowser", "Manage", FormMethod.Post)) <form asp-controller="Manage" asp-action="ForgetBrowser" method="post" class="form-horizontal" role="form">
{
@Html.AntiForgeryToken()
<p> <p>
Browser is curently remembered for two factor: Browser is curently remembered for two factor:
<input type="submit" value="Forget Browser" class="btn btn-default" /> <input type="submit" value="Forget Browser" class="btn btn-default" />
</p> </p>
} </form>
} }
else else
{ {
using (Html.BeginForm("RememberBrowser", "Manage", FormMethod.Post)) <form asp-controller="Manage" asp-action="ForgetBrowser" method="post" class="form-horizontal" role="form">
{
@Html.AntiForgeryToken()
<p> <p>
Browser is curently not remembered for two factor: Browser is curently not remembered for two factor:
<input type="submit" value="Remember Browser" class="btn btn-default" /> <input type="submit" value="Remember Browser" class="btn btn-default" />
</p> </p>
} </form>
} }
</dd> </dd>
</dl> </dl>
</div> </div>

View File

@ -1,5 +1,5 @@
@using Microsoft.AspNet.Http.Authentication; @using Microsoft.AspNet.Http.Authentication;
@model MusicStore.Models.ManageLoginsViewModel @model ManageLoginsViewModel
@{ @{
ViewBag.Title = "Manage your external logins"; ViewBag.Title = "Manage your external logins";
} }
@ -13,21 +13,19 @@
<table class="table"> <table class="table">
<tbody> <tbody>
@foreach (var account in Model.CurrentLogins) @foreach (var account in Model.CurrentLogins)
{ {
<tr> <tr>
<td>@account.LoginProvider</td> <td>@account.LoginProvider</td>
<td> <td>
@if (ViewBag.ShowRemoveButton) @if (ViewBag.ShowRemoveButton)
{ {
using (Html.BeginForm("RemoveLogin", "Manage")) <form asp-controller="Manage" asp-action="RemoveLogin" method="post" class="form-horizontal" role="form">
{
@Html.AntiForgeryToken()
<div> <div>
@Html.Hidden("loginProvider", account.LoginProvider) <input asp-for="@account.LoginProvider" type="hidden" />
@Html.Hidden("providerKey", account.ProviderKey) <input asp-for="@account.ProviderKey" type="hidden" />
<input type="submit" class="btn btn-default" value="Remove" title="Remove this @account.LoginProvider login from your account" /> <input type="submit" class="btn btn-default" value="Remove" title="Remove this @account.LoginProvider login from your account" />
</div> </div>
} </form>
} }
else else
{ {
@ -43,16 +41,14 @@
{ {
<h4>Add another service to log in.</h4> <h4>Add another service to log in.</h4>
<hr /> <hr />
using (Html.BeginForm("LinkLogin", "Manage")) <form asp-controller="Manage" asp-action="LinkLogin" method="post" class="form-horizontal" role="form">
{
@Html.AntiForgeryToken()
<div id="socialLoginList"> <div id="socialLoginList">
<p> <p>
@foreach (AuthenticationDescription p in Model.OtherLogins) @foreach (AuthenticationDescription p in Model.OtherLogins)
{ {
<button type="submit" class="btn btn-default" id="@p.AuthenticationScheme" name="provider" value="@p.AuthenticationScheme" title="Log in using your @p.Caption account">@p.AuthenticationScheme</button> <button type="submit" class="btn btn-default" id="@p.AuthenticationScheme" name="provider" value="@p.AuthenticationScheme" title="Log in using your @p.Caption account">@p.AuthenticationScheme</button>
} }
</p> </p>
</div> </div>
} </form>
} }

View File

@ -1,31 +1,29 @@
@model MusicStore.Models.SetPasswordViewModel @model SetPasswordViewModel
@{ @{
ViewBag.Title = "Create Password"; ViewBag.Title = "Set Password";
} }
<h2>@ViewBag.Title.</h2>
<p class="text-info"> <p class="text-info">
You do not have a local username/password for this site. Add a local You do not have a local username/password for this site. Add a local
account so you can log in without an external login. account so you can log in without an external login.
</p> </p>
@using (Html.BeginForm("SetPassword", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" })) <form asp-controller="Manage" asp-action="SetPassword" method="post" class="form-horizontal" role="form">
{ <h4>Set your password</h4>
@Html.AntiForgeryToken()
<h4>Create Local Login</h4>
<hr /> <hr />
@Html.ValidationSummary("", new { @class = "text-danger" }) <div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
<div class="form-group"> <div class="form-group">
@Html.LabelFor(m => m.NewPassword, new { @class = "col-md-2 control-label" }) <label asp-for="NewPassword" class="col-md-2 control-label"></label>
<div class="col-md-10"> <div class="col-md-10">
@Html.PasswordFor(m => m.NewPassword, new { @class = "form-control" }) <input asp-for="NewPassword" class="form-control" />
<span asp-validation-for="NewPassword" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@Html.LabelFor(m => m.ConfirmPassword, new { @class = "col-md-2 control-label" }) <label asp-for="ConfirmPassword" class="col-md-2 control-label"></label>
<div class="col-md-10"> <div class="col-md-10">
@Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control" }) <input asp-for="ConfirmPassword" class="form-control" />
<span asp-validation-for="ConfirmPassword" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -33,11 +31,8 @@
<input type="submit" value="Set password" class="btn btn-default" /> <input type="submit" value="Set password" class="btn btn-default" />
</div> </div>
</div> </div>
} </form>
@section Scripts { @section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@ @{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
@*@Scripts.Render("~/bundles/jqueryval")*@
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
} }

View File

@ -1,14 +1,12 @@
@model MusicStore.Models.VerifyPhoneNumberViewModel @model VerifyPhoneNumberViewModel
@{ @{
ViewBag.Title = "Verify Phone Number"; ViewBag.Title = "Verify Phone Number";
} }
<h2>@ViewBag.Title.</h2> <h2>@ViewBag.Title.</h2>
@using (Html.BeginForm("VerifyPhoneNumber", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" })) <form asp-controller="Manage" asp-action="VerifyPhoneNumber" method="post" class="form-horizontal" role="form">
{ <input asp-for="PhoneNumber" type="hidden" />
@Html.AntiForgeryToken()
@Html.Hidden("phoneNumber", @Model.PhoneNumber)
<h4>Enter verification code</h4> <h4>Enter verification code</h4>
<p class="text-danger"> <p class="text-danger">
For DEMO only: You can type in this code in the below text box to proceed: @ViewBag.Code For DEMO only: You can type in this code in the below text box to proceed: @ViewBag.Code
@ -16,11 +14,12 @@
Please change this code to register an SMS service in IdentityConfig to send a text message. Please change this code to register an SMS service in IdentityConfig to send a text message.
</p> </p>
<hr /> <hr />
@Html.ValidationSummary("", new { @class = "text-danger" }) <div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
<div class="form-group"> <div class="form-group">
@Html.LabelFor(m => m.Code, new { @class = "col-md-2 control-label" }) <label asp-for="Code" class="col-md-2 control-label"></label>
<div class="col-md-10"> <div class="col-md-10">
@Html.TextBoxFor(m => m.Code, new { @class = "form-control" }) <input asp-for="Code" class="form-control" />
<span asp-validation-for="Code" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -28,11 +27,8 @@
<input type="submit" class="btn btn-default" value="Submit" /> <input type="submit" class="btn btn-default" value="Submit" />
</div> </div>
</div> </div>
} </form>
@section Scripts { @section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@ @{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
@*@Scripts.Render("~/bundles/jqueryval")*@
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
} }

View File

@ -1,10 +1,10 @@
@model MusicStore.Models.Album @model Album
@if (Model != null) @if (Model != null)
{ {
<li> <li>
<br /> <br />
<small><i>@Html.Label(null, "New Arrivals!", new { style = "color: red" })</i></small> <small><i><label title="New Arrivals!" style="color:red">New Arrivals!</label></i></small>
<i>@Html.ActionLink(Model.Title, "Details", "Store", new { id = Model.AlbumId }, new { id = "NewArrivalsPanel" })</i> <i><a id="NewArrivalsPanel" asp-controller="Store" asp-action="Details" asp-route-id="@Model.AlbumId">@Model.Title</a></i>
</li> </li>
} }

View File

@ -1,7 +1,7 @@
@if (ViewBag.CartCount > 0) @if (ViewBag.CartCount > 0)
{ {
<li> <li>
<a href="@Url.Action("Index", "ShoppingCart")" title="@ViewBag.CartSummary"> <a asp-controller="ShoppingCart" asp-action="Index" title="@ViewBag.CartSummary">
<span class="glyphicon glyphicon glyphicon-shopping-cart"></span> <span class="glyphicon glyphicon glyphicon-shopping-cart"></span>
@ViewBag.CartCount @ViewBag.CartCount
</a> </a>

View File

@ -1,19 +1,17 @@
@model IEnumerable<MusicStore.Models.Genre> @model IEnumerable<Genre>
<li class="dropdown"> <li class="dropdown">
<a href="@Url.Action("Index", "Store")" class="dropdown-toggle" data-toggle="dropdown">Store <b class="caret"></b></a> <a asp-controller="Store" asp-action="Index" class="dropdown-toggle" data-toggle="dropdown">Store <b class="caret"></b></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
@foreach (var genre in Model) @foreach (var genre in Model)
{ {
<li> <li>
@Html.ActionLink(genre.Name, <a asp-controller="Store" asp-action="Browse" asp-route-Genre="@genre.Name">@genre.Name</a>
"Browse", "Store",
new { Genre = genre.Name }, null)
</li> </li>
} }
<li class="divider"></li> <li class="divider"></li>
<li> <li>
@Html.ActionLink("More...", "Index", "Store") <a asp-controller="Store" asp-action="Index">More...</a>
</li> </li>
</ul> </ul>
</li> </li>

View File

@ -1,15 +1,25 @@
<!DOCTYPE html> @inject IOptions<AppSettings> AppSettings
<!DOCTYPE html>
<html> <html>
<head> <head>
<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 MVC Music Store</title> <title>@ViewBag.Title @AppSettings.Options.SiteTitle</title>
<environment names="Development,NtlmAuthentication,OpenIdConnect,SocialTesting">
<link rel="stylesheet" href="~/Content/bootstrap.css" />
<link rel="stylesheet" href="~/Content/Site.css" />
<script src="~/Scripts/jquery-2.0.3.js"></script>
</environment>
<environment names="Staging,Production">
<link rel="stylesheet" href="//ajax.aspnetcdn.com/ajax/bootstrap/3.0.0/css/bootstrap.min.css"
asp-fallback-href="~/Content/bootstrap.min.css"
asp-fallback-test-class="hidden"
asp-fallback-test-property="visibility" asp-fallback-test-value="hidden" />
<link rel="stylesheet" href="~/Content/Site.css" />
<script src="~/Scripts/jquery-2.0.3.min.js"></script>
</environment>
@*TODO : Until script helpers are available, adding script references manually*@
@*@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")*@
<link rel="stylesheet" href="~/Content/bootstrap.min.css" />
<link rel="stylesheet" href="~/Content/Site.css" />
<script type="text/javascript" src="~/Scripts/modernizr-2.6.2.js"></script> <script type="text/javascript" src="~/Scripts/modernizr-2.6.2.js"></script>
<script src="~/Scripts/jquery-2.0.3.js"></script> <script src="~/Scripts/jquery-2.0.3.js"></script>
<script src="~/Scripts/jquery.signalR-2.0.1.min.js"></script> <script src="~/Scripts/jquery.signalR-2.0.1.min.js"></script>
@ -41,11 +51,11 @@
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </button>
@Html.ActionLink("ASP.NET MVC Music Store", "Index", "Home", null, new { @class = "navbar-brand" }) <a asp-controller="Home" asp-action="Index" class="navbar-brand">@AppSettings.Options.SiteTitle</a>
</div> </div>
<div class="navbar-collapse collapse"> <div class="navbar-collapse collapse">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li>@Html.ActionLink("Home", "Index", "Home")</li> <li><a asp-controller="Home" asp-action="Index">Home</a></li>
@await Component.InvokeAsync("GenreMenu") @await Component.InvokeAsync("GenreMenu")
@await Component.InvokeAsync("CartSummary") @await Component.InvokeAsync("CartSummary")
@await Component.InvokeAsync("Announcement") @await Component.InvokeAsync("Announcement")
@ -63,11 +73,20 @@
</footer> </footer>
</div> </div>
@*TODO : Until script helpers are available, adding script references manually*@ <environment names="Development,NtlmAuthentication,OpenIdConnect,SocialTesting">
@*@Scripts.Render("~/bundles/jquery") <script src="~/Scripts/bootstrap.js"></script>
@Scripts.Render("~/bundles/bootstrap")*@ <script src="~/Scripts/respond.js"></script>
<script src="~/Scripts/bootstrap.js"></script> </environment>
<script src="~/Scripts/respond.js"></script> <environment names="Staging,Production">
<script src="//ajax.aspnetcdn.com/ajax/bootstrap/3.0.0/bootstrap.min.js"
asp-fallback-src="~/Scripts/bootstrap.min.js"
asp-fallback-test="window.jQuery">
</script>
<script src="//ajax.aspnetcdn.com/ajax/respond/1.2.0/respond.js"
asp-fallback-src="~/Scripts/respond.js">
</script>
</environment>
@RenderSection("scripts", required: false) @RenderSection("scripts", required: false)
</body> </body>
</html> </html>

View File

@ -2,19 +2,15 @@
@if (User.IsSignedIn()) @if (User.IsSignedIn())
{ {
using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" })) <form asp-controller="Account" asp-action="LogOff" method="post" id="logoutForm" class="navbar-right">
{
@Html.AntiForgeryToken()
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<li> <li>
@Html.ActionLink("Hello " + User.GetUserName() + "!", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" }) <a asp-controller="Manage" asp-action="Index" title="Manage">Hello @User.GetUserName()!</a>
</li> </li>
<li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li> <li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li>
</ul> </ul>
} </form>
} }
//Either NTLM will be used or social authentication will be used. Based on the authentication schemes enabled remove an unused block.
else if (User.Identity.IsAuthenticated) else if (User.Identity.IsAuthenticated)
{ {
//This code block necessary only for NTLM authentication //This code block necessary only for NTLM authentication
@ -27,7 +23,7 @@ else if (User.Identity.IsAuthenticated)
else else
{ {
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<li>@Html.ActionLink("Register", "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" })</li> <li><a id="registerLink" asp-controller="Account" asp-action="Register">Register</a></li>
<li>@Html.ActionLink("Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" })</li> <li><a id="loginLink" asp-controller="Account" asp-action="Login">Log in</a></li>
</ul> </ul>
} }

View File

@ -0,0 +1,14 @@
<environment names="Development,NtlmAuthentication,OpenIdConnect,SocialTesting">
<script src="~/Scripts/jquery.validate.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
</environment>
<environment names="Staging,Production">
<script src="//ajax.aspnetcdn.com/ajax/jquery.validation/1.11.1/jquery.validate.min.js"
asp-fallback-src="~/Scripts/jquery.validate.js"
asp-fallback-test="window.jquery && window.jquery.validator">
</script>
<script src="//ajax.aspnetcdn.com/ajax/mvc/5.2.3/jquery.validate.unobtrusive.min.js"
asp-fallback-src="~/Scripts/jquery.validate.unobtrusive.min.js"
asp-fallback-test="window.jquery && window.jquery.validator && window.jquery.validator.unobtrusive">
</script>
</environment>

View File

@ -55,7 +55,7 @@
<em>Review</em> your cart: <em>Review</em> your cart:
</h3> </h3>
<p class="button"> <p class="button">
@Html.ActionLink("Checkout >>", "AddressAndPayment", "Checkout") <a asp-controller="Checkout" asp-action="AddressAndPayment">Checkout >></a>
</p> </p>
<div id="update-message"> <div id="update-message">
</div> </div>
@ -76,8 +76,7 @@
{ {
<tr id="row-@item.CartItemId"> <tr id="row-@item.CartItemId">
<td> <td>
@Html.ActionLink(item.Album.Title, <a asp-controller="Store" asp-action="Details" asp-route-id="@item.AlbumId">@item.Album.Title</a>
"Details", "Store", new { id = item.AlbumId }, null)
</td> </td>
<td> <td>
@item.Album.Price @item.Album.Price

View File

@ -1,4 +1,4 @@
@model MusicStore.Models.Genre @model Genre
@{ @{
ViewBag.Title = "Browse Albums"; ViewBag.Title = "Browse Albums";
} }
@ -11,7 +11,7 @@
@foreach (var album in Model.Albums) @foreach (var album in Model.Albums)
{ {
<li class="col-lg-2 col-md-2 col-sm-2 col-xs-4 container"> <li class="col-lg-2 col-md-2 col-sm-2 col-xs-4 container">
<a href="@Url.Action("Details", new { id = album.AlbumId })"> <a asp-controller="Store" asp-action="Details" asp-route-id="@album.AlbumId">
@if (!string.IsNullOrEmpty(album.AlbumArtUrl)) @if (!string.IsNullOrEmpty(album.AlbumArtUrl))
{ {
<img alt="@album.Title" src="@Url.Content(@album.AlbumArtUrl)" /> <img alt="@album.Title" src="@Url.Content(@album.AlbumArtUrl)" />

View File

@ -1,4 +1,4 @@
@model MusicStore.Models.Album @model Album
@{ @{
ViewBag.Title = "Album - " + Model.Title; ViewBag.Title = "Album - " + Model.Title;
@ -21,9 +21,9 @@
</p> </p>
<p> <p>
<em>Price:</em> <em>Price:</em>
@Html.DisplayFor(model => model.Price) <label>@Model.Price</label>
</p> </p>
<p class="button"> <p class="button">
@Html.ActionLink("Add to cart", "AddToCart", "ShoppingCart", new { id = Model.AlbumId }) <a asp-controller="ShoppingCart" asp-action="AddToCart" asp-route-id="@Model.AlbumId">Add to cart</a>
</p> </p>
</div> </div>

View File

@ -1,4 +1,4 @@
@model IEnumerable<MusicStore.Models.Genre> @model IEnumerable<Genre>
@{ @{
ViewBag.Title = "Store"; ViewBag.Title = "Store";
} }
@ -10,6 +10,6 @@
<ul class="list-group"> <ul class="list-group">
@foreach (var genre in Model) @foreach (var genre in Model)
{ {
<li class="list-group-item">@Html.ActionLink(genre.Name, "Browse", new { genre = genre.Name })</li> <li class="list-group-item"><a asp-controller="Store" asp-action="Browse" asp-route-genre="@genre.Name">@genre.Name</a></li>
} }
</ul> </ul>

View File

@ -0,0 +1,5 @@
@using MusicStore
@using MusicStore.Models
@using Microsoft.Framework.OptionsModel
@using Microsoft.AspNet.Identity
@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"

View File

@ -1,4 +1,7 @@
{ {
"AppSettings": {
"SiteTitle": "ASP.NET MVC Music Store"
},
"DefaultAdminUsername": "Administrator@test.com", "DefaultAdminUsername": "Administrator@test.com",
"DefaultAdminPassword": "YouShouldChangeThisPassword1!", "DefaultAdminPassword": "YouShouldChangeThisPassword1!",
"Data": { "Data": {

View File

@ -24,11 +24,13 @@
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-*", "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-*",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-*", "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-*",
"Microsoft.AspNet.Mvc": "6.0.0-*", "Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-*",
"Microsoft.AspNet.Server.IIS": "1.0.0-*", "Microsoft.AspNet.Server.IIS": "1.0.0-*",
"Microsoft.AspNet.Server.WebListener": "1.0.0-*", "Microsoft.AspNet.Server.WebListener": "1.0.0-*",
"Microsoft.AspNet.Session": "1.0.0-*", "Microsoft.AspNet.Session": "1.0.0-*",
"Microsoft.AspNet.SignalR.Server": "3.0.0-*", "Microsoft.AspNet.SignalR.Server": "3.0.0-*",
"Microsoft.AspNet.StaticFiles": "1.0.0-*", "Microsoft.AspNet.StaticFiles": "1.0.0-*",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-*",
"Microsoft.Framework.Caching.Distributed": "1.0.0-*", // For Session. "Microsoft.Framework.Caching.Distributed": "1.0.0-*", // For Session.
"Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-*", "Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-*",
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-*", "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-*",

View File

@ -419,7 +419,7 @@ namespace E2ETests
} }
catch (Exception exception) catch (Exception exception)
{ {
logger.LogWarning("Failed to delete directory.", exception); logger.LogWarning("Failed to delete directory : {error}", exception.Message);
} }
} }
} }

View File

@ -34,11 +34,11 @@ namespace E2ETests
#endif #endif
) )
{ {
logger.LogWarning("Failed to complete the request.", exception); logger.LogWarning("Failed to complete the request : {0}.", exception.Message);
Thread.Sleep(7 * 1000); //Wait for a while before retry. Thread.Sleep(7 * 1000); //Wait for a while before retry.
} }
} }
} }
} }
} }
} }

View File

@ -46,7 +46,7 @@ namespace E2ETests
{ {
foreach (XmlNode input in htmlDocument.GetElementsByTagName("input")) foreach (XmlNode input in htmlDocument.GetElementsByTagName("input"))
{ {
if (input.Attributes["name"].Value == "__RequestVerificationToken" && input.Attributes["type"].Value == "hidden") if (input.Attributes["name"]?.Value == "__RequestVerificationToken" && input.Attributes["type"].Value == "hidden")
{ {
return input.Attributes["value"].Value; return input.Attributes["value"].Value;
} }

View File

@ -43,7 +43,7 @@ namespace E2ETests
Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(HttpStatusCode.OK, response.StatusCode);
ValidateLayoutPage(responseContent); ValidateLayoutPage(responseContent);
Assert.Contains(PrefixBaseAddress("<a href=\"/{0}/Store/Details/"), responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains(PrefixBaseAddress("<a href=\"/{0}/Store/Details/"), responseContent, StringComparison.OrdinalIgnoreCase);
Assert.Contains("<title>Home Page MVC Music Store</title>", responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("<title>Home Page ASP.NET MVC Music Store</title>", responseContent, StringComparison.OrdinalIgnoreCase);
if (!useNtlmAuthentication) if (!useNtlmAuthentication)
{ {
@ -87,7 +87,7 @@ namespace E2ETests
{ {
Assert.Contains("ASP.NET MVC Music Store", responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("ASP.NET MVC Music Store", responseContent, StringComparison.OrdinalIgnoreCase);
Assert.Contains(PrefixBaseAddress("<li><a href=\"/{0}\">Home</a></li>"), responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains(PrefixBaseAddress("<li><a href=\"/{0}\">Home</a></li>"), responseContent, StringComparison.OrdinalIgnoreCase);
Assert.Contains(PrefixBaseAddress("<a href=\"/{0}/Store\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">Store <b class=\"caret\"></b></a>"), responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains(PrefixBaseAddress("<a class=\"dropdown-toggle\" data-toggle=\"dropdown\" href=\"/{0}/Store\">Store <b class=\"caret\"></b></a>"), responseContent, StringComparison.OrdinalIgnoreCase);
Assert.Contains("<ul class=\"dropdown-menu\">", responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("<ul class=\"dropdown-menu\">", responseContent, StringComparison.OrdinalIgnoreCase);
Assert.Contains("<li class=\"divider\"></li>", responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("<li class=\"divider\"></li>", responseContent, StringComparison.OrdinalIgnoreCase);
} }
@ -99,7 +99,7 @@ namespace E2ETests
ThrowIfResponseStatusNotOk(response); ThrowIfResponseStatusNotOk(response);
var responseContent = response.Content.ReadAsStringAsync().Result; var responseContent = response.Content.ReadAsStringAsync().Result;
ValidateLayoutPage(responseContent); ValidateLayoutPage(responseContent);
Assert.Contains("<title>Log in MVC Music Store</title>", responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("<title>Log in ASP.NET MVC Music Store</title>", responseContent, StringComparison.OrdinalIgnoreCase);
Assert.Contains("<h4>Use a local account to log in.</h4>", responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("<h4>Use a local account to log in.</h4>", responseContent, StringComparison.OrdinalIgnoreCase);
Assert.Equal<string>(_applicationBaseUrl + PrefixBaseAddress("Account/Login?ReturnUrl=%2F{0}%2FAdmin%2FStoreManager%2F"), response.RequestMessage.RequestUri.AbsoluteUri); Assert.Equal<string>(_applicationBaseUrl + PrefixBaseAddress("Account/Login?ReturnUrl=%2F{0}%2FAdmin%2FStoreManager%2F"), response.RequestMessage.RequestUri.AbsoluteUri);
_logger.LogInformation("Redirected to login page as expected."); _logger.LogInformation("Redirected to login page as expected.");
@ -137,7 +137,7 @@ namespace E2ETests
response = _httpClient.PostAsync("Account/Register", content).Result; response = _httpClient.PostAsync("Account/Register", content).Result;
responseContent = response.Content.ReadAsStringAsync().Result; responseContent = response.Content.ReadAsStringAsync().Result;
Assert.Null(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application")); Assert.Null(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
Assert.Contains("<div class=\"validation-summary-errors text-danger\" data-valmsg-summary=\"true\"><ul><li>The password and confirmation password do not match.</li>", responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("<div class=\"text-danger validation-summary-errors\" data-valmsg-summary=\"true\"><ul><li>The password and confirmation password do not match.</li>", responseContent, StringComparison.OrdinalIgnoreCase);
_logger.LogInformation("Server side model validator rejected the user '{email}''s registration as passwords do not match.", generatedEmail); _logger.LogInformation("Server side model validator rejected the user '{email}''s registration as passwords do not match.", generatedEmail);
} }
@ -249,7 +249,7 @@ namespace E2ETests
var content = new FormUrlEncodedContent(formParameters.ToArray()); var content = new FormUrlEncodedContent(formParameters.ToArray());
response = _httpClient.PostAsync("Account/Login", content).Result; response = _httpClient.PostAsync("Account/Login", content).Result;
responseContent = response.Content.ReadAsStringAsync().Result; responseContent = response.Content.ReadAsStringAsync().Result;
Assert.Contains("<div class=\"validation-summary-errors text-danger\"><ul><li>Invalid login attempt.</li>", responseContent, StringComparison.OrdinalIgnoreCase); Assert.Contains("<div class=\"text-danger validation-summary-errors\" data-valmsg-summary=\"true\"><ul><li>Invalid login attempt.</li>", responseContent, StringComparison.OrdinalIgnoreCase);
//Verify cookie not sent //Verify cookie not sent
Assert.Null(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application")); Assert.Null(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
_logger.LogInformation("Identity successfully prevented an invalid user login."); _logger.LogInformation("Identity successfully prevented an invalid user login.");

View File

@ -31,6 +31,8 @@ namespace MusicStore
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.Configure<AppSettings>(Configuration.GetSubKey("AppSettings"));
//Sql client not available on mono //Sql client not available on mono
var useInMemoryStore = Type.GetType("Mono.Runtime") != null; var useInMemoryStore = Type.GetType("Mono.Runtime") != null;

View File

@ -39,6 +39,8 @@ namespace MusicStore
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.Configure<AppSettings>(Configuration.GetSubKey("AppSettings"));
//Sql client not available on mono //Sql client not available on mono
string value; string value;
var useInMemoryStore = Configuration.TryGet("UseInMemoryStore", out value) && value == "true" ? var useInMemoryStore = Configuration.TryGet("UseInMemoryStore", out value) && value == "true" ?