diff --git a/src/MusicStore/Components/GenreMenuComponent.cs b/src/MusicStore/Components/GenreMenuComponent.cs new file mode 100644 index 0000000000..aa38b5687a --- /dev/null +++ b/src/MusicStore/Components/GenreMenuComponent.cs @@ -0,0 +1,29 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNet.Mvc; +using MusicStore.Models; + +namespace MusicStore.Components +{ + [ViewComponent(Name = "GenreMenu")] + public class GenreMenuComponent : ViewComponent + { + private MusicStoreContext db = new MusicStoreContext(); + public async Task InvokeAsync() + { + // TODO [EF] We don't query related data as yet, so the OrderByDescending isn't doing anything + //var genres = db.Genres + //.OrderByDescending( + // g => g.Albums.Sum( + // a => a.OrderDetails.Sum( + // od => od.Quantity))) + //.Take(9) + //.ToList(); + + var genres = db.Genres.ToList(); + + return View(genres); + } + } +} \ No newline at end of file diff --git a/src/MusicStore/Controllers/AccountController.cs b/src/MusicStore/Controllers/AccountController.cs index d214df821d..7f58cd1372 100644 --- a/src/MusicStore/Controllers/AccountController.cs +++ b/src/MusicStore/Controllers/AccountController.cs @@ -17,16 +17,16 @@ namespace MusicStore.Controllers public AccountController() //Bug: No EF yet - using an in memory store //: this(new UserManager(new UserStore(new ApplicationDbContext()))) - : this(new UserManager(new InMemoryUserStore())) + : this(new UserManager(new InMemoryUserStore())) { } - public AccountController(UserManager userManager) + public AccountController(UserManager userManager) { UserManager = userManager; } - public UserManager UserManager { get; private set; } + public UserManager UserManager { get; private set; } // // GET: /Account/Login @@ -47,7 +47,7 @@ namespace MusicStore.Controllers { if (ModelState.IsValid == true) { - var user = await UserManager.Find(model.UserName, model.Password); + var user = await UserManager.FindByUserNamePassword(model.UserName, model.Password); if (user != null) { await SignIn(user, model.RememberMe); @@ -82,7 +82,7 @@ namespace MusicStore.Controllers if (ModelState.IsValid == true) { var user = new ApplicationUser() { UserName = model.UserName }; - var result = await UserManager.Create(user, model.Password); + var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignIn(user, isPersistent: false); @@ -108,7 +108,8 @@ namespace MusicStore.Controllers { ManageMessageId? message = null; - IdentityResult result = await UserManager.RemoveLogin(this.Context.User.Identity.GetUserId(), new UserLoginInfo(loginProvider, providerKey)); + var user = new ApplicationUser() { UserName = this.Context.User.Identity.GetUserId() }; + IdentityResult result = await UserManager.RemoveLogin(user, new UserLoginInfo(loginProvider, providerKey)); if (result.Succeeded) { message = ManageMessageId.RemoveLoginSuccess; @@ -155,7 +156,8 @@ namespace MusicStore.Controllers { if (ModelState.IsValid == true) { - IdentityResult result = await UserManager.ChangePassword(this.Context.User.Identity.GetUserId(), model.OldPassword, model.NewPassword); + var user = new ApplicationUser() { UserName = this.Context.User.Identity.GetUserId() }; + IdentityResult result = await UserManager.ChangePasswordAsync(user, model.OldPassword, model.NewPassword); if (result.Succeeded) { //Bug: No helper method @@ -181,7 +183,8 @@ namespace MusicStore.Controllers if (ModelState.IsValid == true) { - IdentityResult result = await UserManager.AddPassword(this.Context.User.Identity.GetUserId(), model.NewPassword); + var user = new ApplicationUser() { UserName = this.Context.User.Identity.GetUserId() }; + IdentityResult result = await UserManager.ChangePasswordAsync(user, model.OldPassword, model.NewPassword); if (result.Succeeded) { //Bug: No helper method @@ -224,7 +227,7 @@ namespace MusicStore.Controllers } // Sign in the user with this external login provider if the user already has a login - var user = await UserManager.Find(loginInfo.Login); + var user = await UserManager.FindByLoginAsync(loginInfo.Login); if (user != null) { await SignIn(user, isPersistent: false); @@ -261,7 +264,8 @@ namespace MusicStore.Controllers //return RedirectToAction("Manage", new { Message = ManageMessageId.Error }); return View(); } - var result = await UserManager.AddLogin(this.Context.User.Identity.GetUserId(), loginInfo.Login); + var user = new ApplicationUser() { UserName = this.Context.User.Identity.GetUserId()}; + var result = await UserManager.AddLogin(user, loginInfo.Login); if (result.Succeeded) { //Bug: No helper method @@ -298,10 +302,10 @@ namespace MusicStore.Controllers } var user = new ApplicationUser() { UserName = model.UserName }; - var result = await UserManager.Create(user); + var result = await UserManager.CreateAsync(user); if (result.Succeeded) { - result = await UserManager.AddLogin(user.Id, info.Login); + result = await UserManager.AddLogin(user, info.Login); if (result.Succeeded) { await SignIn(user, isPersistent: false); @@ -340,7 +344,8 @@ namespace MusicStore.Controllers //[ChildActionOnly] public async Task RemoveAccountList() { - var linkedAccounts = await UserManager.GetLogins(this.Context.User.Identity.GetUserId()); + var user = new ApplicationUser() { UserName = this.Context.User.Identity.GetUserId() }; + var linkedAccounts = await UserManager.GetLogins(user); ViewBag.ShowRemoveButton = await HasPassword() || linkedAccounts.Count > 1; //Bug: We dont have partial views yet //return (IActionResult)PartialView("_RemoveAccountPartial", linkedAccounts); @@ -380,7 +385,7 @@ namespace MusicStore.Controllers private async Task HasPassword() { - var user = await UserManager.FindById(this.Context.User.Identity.GetUserId()); + var user = await UserManager.FindByIdAsync(this.Context.User.Identity.GetUserId()); if (user != null) { return user.PasswordHash != null; diff --git a/src/MusicStore/Controllers/HomeController.cs b/src/MusicStore/Controllers/HomeController.cs index af032c7c8a..ef86126350 100644 --- a/src/MusicStore/Controllers/HomeController.cs +++ b/src/MusicStore/Controllers/HomeController.cs @@ -3,7 +3,7 @@ using MusicStore.Models; using System.Collections.Generic; using System.Linq; -namespace MvcMusicStore.Controllers +namespace MusicStore.Controllers { public class HomeController : Controller { diff --git a/src/MusicStore/Controllers/ShoppingCartController.cs b/src/MusicStore/Controllers/ShoppingCartController.cs index c08394d149..803f792c0f 100644 --- a/src/MusicStore/Controllers/ShoppingCartController.cs +++ b/src/MusicStore/Controllers/ShoppingCartController.cs @@ -84,9 +84,7 @@ namespace MusicStore.Controllers DeleteId = id }; - //Bug: Missing helper - //return Json(results); - return new JsonResult(results); + return Json(results); } } } \ No newline at end of file diff --git a/src/MusicStore/Controllers/StoreController.cs b/src/MusicStore/Controllers/StoreController.cs index 623199c133..ad04894fa2 100644 --- a/src/MusicStore/Controllers/StoreController.cs +++ b/src/MusicStore/Controllers/StoreController.cs @@ -36,25 +36,11 @@ namespace MusicStore.Controllers { var album = db.Albums.Single(a => a.AlbumId == id); + // TODO [EF] We don't query related data as yet. We have to populate this until we do automatically. + album.Genre = db.Genres.Single(g => g.GenreId == album.GenreId); + album.Artist = db.Artists.Single(a => a.ArtistId == album.ArtistId); + return View(album); } - - ///Bug: Missing [ChildActionOnly] attribute - //[ChildActionOnly] - public IActionResult GenreMenu() - { - // TODO [EF] We don't query related data as yet, so the OrderByDescending isn't doing anything - var genres = db.Genres - .OrderByDescending( - g => g.Albums.Sum( - a => a.OrderDetails.Sum( - od => od.Quantity))) - .Take(9) - .ToList(); - - //Bug: Missing PartialView method. - //return PartialView(genres); - return View(); - } } } \ No newline at end of file diff --git a/src/MusicStore/Controllers/StoreManagerController.cs b/src/MusicStore/Controllers/StoreManagerController.cs index 8a0fb87164..2ce2300236 100644 --- a/src/MusicStore/Controllers/StoreManagerController.cs +++ b/src/MusicStore/Controllers/StoreManagerController.cs @@ -34,12 +34,17 @@ namespace MusicStore.Controllers public IActionResult Details(int id = 0) { Album album = db.Albums.Single(a => a.AlbumId == id); + if (album == null) { //Bug: Need method HttpNotFound() on Controller //return HttpNotFound(); return new HttpStatusCodeResult(404); } + + // TODO [EF] We don't query related data as yet. We have to populate this until we do automatically. + album.Genre = db.Genres.Single(g => g.GenreId == album.GenreId); + album.Artist = db.Artists.Single(a => a.ArtistId == album.ArtistId); return View(album); } diff --git a/src/MusicStore/LKG.json b/src/MusicStore/LKG.json index a742464bf1..7500966fde 100644 --- a/src/MusicStore/LKG.json +++ b/src/MusicStore/LKG.json @@ -1,32 +1,32 @@ { "version": "0.1-alpha-*", "dependencies": { - "Helios": "0.1-alpha-168", - "Microsoft.AspNet.Abstractions": "0.1-alpha-210", - "Microsoft.AspNet.Mvc": "0.1-alpha-449", + "Helios": "0.1-alpha-191", + "Microsoft.AspNet.Abstractions": "0.1-alpha-220", + "Microsoft.AspNet.Mvc": "0.1-alpha-490", "Microsoft.AspNet.Razor": "0.1-alpha-181", "Microsoft.AspNet.ConfigurationModel": "0.1-alpha-167", - "Microsoft.AspNet.DependencyInjection": "0.1-alpha-232", - "Microsoft.AspNet.RequestContainer": "0.1-alpha-201", - "Microsoft.AspNet.Routing": "0.1-alpha-182", - "Microsoft.AspNet.Mvc.ModelBinding": "0.1-alpha-449", - "Microsoft.AspNet.Mvc.Core": "0.1-alpha-449", - "Microsoft.AspNet.Mvc.Razor": "0.1-alpha-449", - "Microsoft.AspNet.Mvc.Rendering": "0.1-alpha-449", - "Microsoft.AspNet.StaticFiles": "0.1-alpha-146", - "System.Security.Claims": "0.1-alpha-094", + "Microsoft.AspNet.DependencyInjection": "0.1-alpha-234", + "Microsoft.AspNet.RequestContainer": "0.1-alpha-213", + "Microsoft.AspNet.Routing": "0.1-alpha-195", + "Microsoft.AspNet.Mvc.ModelBinding": "0.1-alpha-490", + "Microsoft.AspNet.Mvc.Core": "0.1-alpha-490", + "Microsoft.AspNet.Mvc.Razor": "0.1-alpha-490", + "Microsoft.AspNet.Mvc.Rendering": "0.1-alpha-490", + "Microsoft.AspNet.StaticFiles": "0.1-alpha-158", + "System.Security.Claims": "0.1-alpha-103", "System.Security.Principal": "4.0.0.0", "Microsoft.AspNet.Security.DataProtection": "0.1-alpha-141", - "Microsoft.AspNet.Identity": "0.1-alpha-238", - "Microsoft.AspNet.Identity.Entity": "0.1-alpha-238", - "Microsoft.AspNet.Identity.InMemory": "0.1-alpha-238", - "Microsoft.Data.Entity": "0.1-alpha-380", - "Microsoft.Data.Relational": "0.1-alpha-380", - "Microsoft.Data.SqlServer": "0.1-pre-380", - "Microsoft.Data.InMemory": "0.1-alpha-380", - "Microsoft.AspNet.Diagnostics": "0.1-alpha-081", - "Microsoft.AspNet.Hosting": "0.1-alpha-201", - "Microsoft.AspNet.Server.WebListener": "0.1-alpha-105" + "Microsoft.AspNet.Identity": "0.1-alpha-264", + "Microsoft.AspNet.Identity.Entity": "0.1-alpha-264", + "Microsoft.AspNet.Identity.InMemory": "0.1-alpha-264", + "Microsoft.Data.Entity": "0.1-alpha-390", + "Microsoft.Data.Relational": "0.1-alpha-390", + "Microsoft.Data.SqlServer": "0.1-pre-390", + "Microsoft.Data.InMemory": "0.1-alpha-390", + "Microsoft.AspNet.Diagnostics": "0.1-alpha-094", + "Microsoft.AspNet.Hosting": "0.1-alpha-213", + "Microsoft.AspNet.Server.WebListener": "0.1-alpha-128" }, "configurations": { "net45": { diff --git a/src/MusicStore/Models/SampleData.cs b/src/MusicStore/Models/SampleData.cs index b2c65f1e11..41a44ecd75 100644 --- a/src/MusicStore/Models/SampleData.cs +++ b/src/MusicStore/Models/SampleData.cs @@ -13,9 +13,7 @@ namespace MusicStore.Web.Models { public static class SampleData { - //Bug: Currently a ~ in the url results in an razor exception: https://github.com/aspnet/WebFx/issues/66 - //const string imgUrl = "~/Images/placeholder.png"; - const string imgUrl = "/Images/placeholder.png"; + const string imgUrl = "~/Images/placeholder.png"; public static void InitializeMusicStoreDatabase() { diff --git a/src/MusicStore/Startup.cs b/src/MusicStore/Startup.cs index b83d58b467..1b83851077 100644 --- a/src/MusicStore/Startup.cs +++ b/src/MusicStore/Startup.cs @@ -82,22 +82,22 @@ public class Startup string _password = "YouShouldChangeThisPassword"; // configuration.Get("DefaultAdminPassword"); string _role = "Administrator"; - var userManager = new UserManager(new InMemoryUserStore()); - var roleManager = new RoleManager(new InMemoryRoleStore()); + var userManager = new UserManager(new InMemoryUserStore()); + var roleManager = new RoleManager(new InMemoryRoleStore()); var role = new InMemoryRole(_role); - var result = await roleManager.RoleExists(_role); + var result = await roleManager.RoleExistsAsync(_role); if (result == false) { - await roleManager.Create(role); + await roleManager.CreateAsync(role); } - var user = await userManager.FindByName(_username); + var user = await userManager.FindByNameAsync(_username); if (user == null) { user = new ApplicationUser { UserName = _username }; - await userManager.Create(user, _password); - await userManager.AddToRole(user.Id, _role); + await userManager.CreateAsync(user, _password); + await userManager.AddToRoleAsync(user, _role); } } } \ No newline at end of file diff --git a/src/MusicStore/Views/Account/ExternalLoginConfirmation.cshtml b/src/MusicStore/Views/Account/ExternalLoginConfirmation.cshtml new file mode 100644 index 0000000000..c0690507ab --- /dev/null +++ b/src/MusicStore/Views/Account/ExternalLoginConfirmation.cshtml @@ -0,0 +1,36 @@ +@model MusicStore.Models.ExternalLoginConfirmationViewModel +@{ + ViewBag.Title = "Register"; +} +

@ViewBag.Title.

+

Associate your @ViewBag.LoginProvider account.

+ +@using (Html.BeginForm("ExternalLoginConfirmation", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" })) +{ + @Html.AntiForgeryToken() + +

Association Form

+
+ @Html.ValidationSummary(true) +

+ You've successfully authenticated with @ViewBag.LoginProvider. + Please enter a user name for this site below and click the Register button to finish + logging in. +

+
+ @Html.LabelFor(m => m.UserName, new { @class = "col-md-2 control-label" }) +
+ @Html.TextBoxFor(m => m.UserName, new { @class = "form-control" }) + @Html.ValidationMessageFor(m => m.UserName) +
+
+
+
+ +
+
+} + +@section Scripts { + @Scripts.Render("~/bundles/jqueryval") +} diff --git a/src/MusicStore/Views/Account/ExternalLoginFailure.cshtml b/src/MusicStore/Views/Account/ExternalLoginFailure.cshtml new file mode 100644 index 0000000000..c3d56e01d5 --- /dev/null +++ b/src/MusicStore/Views/Account/ExternalLoginFailure.cshtml @@ -0,0 +1,8 @@ +@{ + //Bug: Need a way to specify the layout page in a single place + Layout = "/Views/Shared/_Layout.cshtml"; + ViewBag.Title = "Login Failure"; +} + +

@ViewBag.Title.

+

Unsuccessful login with service.

diff --git a/src/MusicStore/Views/Account/Login.cshtml b/src/MusicStore/Views/Account/Login.cshtml new file mode 100644 index 0000000000..011e5db254 --- /dev/null +++ b/src/MusicStore/Views/Account/Login.cshtml @@ -0,0 +1,60 @@ +@model MusicStore.Models.LoginViewModel + +@{ + //Bug: Need a way to specify the layout page in a single place + Layout = "/Views/Shared/_Layout.cshtml"; + ViewBag.Title = "Log in"; +} + +

@ViewBag.Title.

+
+
+
+ @using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" })) + { + @Html.AntiForgeryToken() +

Use a local account to log in.

+
+ @Html.ValidationSummary(true) +
+ @Html.LabelFor(m => m.UserName, new { @class = "col-md-2 control-label" }) +
+ @Html.TextBoxFor(m => m.UserName, new { @class = "form-control" }) + @Html.ValidationMessageFor(m => m.UserName) +
+
+
+ @Html.LabelFor(m => m.Password, new { @class = "col-md-2 control-label" }) +
+ @Html.PasswordFor(m => m.Password, new { @class = "form-control" }) + @Html.ValidationMessageFor(m => m.Password) +
+
+
+
+
+ @Html.CheckBoxFor(m => m.RememberMe) + @Html.LabelFor(m => m.RememberMe) +
+
+
+
+
+ +
+
+

+ @Html.ActionLink("Register", "Register") if you don't have a local account. +

+ } +
+
+
+
+ @Html.Partial("_ExternalLoginsListPartial", new { Action = "ExternalLogin", ReturnUrl = ViewBag.ReturnUrl }) +
+
+
+@section Scripts { + @Scripts.Render("~/bundles/jqueryval") +} \ No newline at end of file diff --git a/src/MusicStore/Views/Account/Manage.cshtml b/src/MusicStore/Views/Account/Manage.cshtml new file mode 100644 index 0000000000..4a1c201902 --- /dev/null +++ b/src/MusicStore/Views/Account/Manage.cshtml @@ -0,0 +1,31 @@ +@using MusicStore.Models; +@using Microsoft.AspNet.Identity; +@{ + //Bug: Need a way to specify the layout page in a single place + Layout = "/Views/Shared/_Layout.cshtml"; + ViewBag.Title = "Manage Account"; +} + +

@ViewBag.Title.

+ +

@ViewBag.StatusMessage

+
+
+ @if (ViewBag.HasLocalPassword) + { + @Html.Partial("_ChangePasswordPartial") + } + else + { + @Html.Partial("_SetPasswordPartial") + } + +
+ @Html.Action("RemoveAccountList") + @Html.Partial("_ExternalLoginsListPartial", new { Action = "LinkLogin", ReturnUrl = ViewBag.ReturnUrl }) +
+
+
+@section Scripts { + @Scripts.Render("~/bundles/jqueryval") +} \ No newline at end of file diff --git a/src/MusicStore/Views/Account/Register.cshtml b/src/MusicStore/Views/Account/Register.cshtml new file mode 100644 index 0000000000..1306c612b1 --- /dev/null +++ b/src/MusicStore/Views/Account/Register.cshtml @@ -0,0 +1,43 @@ +@model MusicStore.Models.RegisterViewModel +@{ + //Bug: Need a way to specify the layout page in a single place + Layout = "/Views/Shared/_Layout.cshtml"; + ViewBag.Title = "Register"; +} + +

@ViewBag.Title.

+ +@using (Html.BeginForm("Register", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" })) +{ + @Html.AntiForgeryToken() +

Create a new account.

+
+ @Html.ValidationSummary() +
+ @Html.LabelFor(m => m.UserName, new { @class = "col-md-2 control-label" }) +
+ @Html.TextBoxFor(m => m.UserName, new { @class = "form-control" }) +
+
+
+ @Html.LabelFor(m => m.Password, new { @class = "col-md-2 control-label" }) +
+ @Html.PasswordFor(m => m.Password, new { @class = "form-control" }) +
+
+
+ @Html.LabelFor(m => m.ConfirmPassword, new { @class = "col-md-2 control-label" }) +
+ @Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control" }) +
+
+
+
+ +
+
+} + +@section Scripts { + @Scripts.Render("~/bundles/jqueryval") +} \ No newline at end of file diff --git a/src/MusicStore/Views/Account/_ChangePasswordPartial.cshtml b/src/MusicStore/Views/Account/_ChangePasswordPartial.cshtml new file mode 100644 index 0000000000..2363c3340b --- /dev/null +++ b/src/MusicStore/Views/Account/_ChangePasswordPartial.cshtml @@ -0,0 +1,36 @@ +@using Microsoft.AspNet.Identity +@model MusicStore.Models.ManageUserViewModel + +

You're logged in as @User.Identity.GetUserName().

+ +@using (Html.BeginForm("Manage", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" })) +{ + @Html.AntiForgeryToken() +

Change Password Form

+
+ @Html.ValidationSummary() +
+ @Html.LabelFor(m => m.OldPassword, new { @class = "col-md-2 control-label" }) +
+ @Html.PasswordFor(m => m.OldPassword, new { @class = "form-control" }) +
+
+
+ @Html.LabelFor(m => m.NewPassword, new { @class = "col-md-2 control-label" }) +
+ @Html.PasswordFor(m => m.NewPassword, new { @class = "form-control" }) +
+
+
+ @Html.LabelFor(m => m.ConfirmPassword, new { @class = "col-md-2 control-label" }) +
+ @Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control" }) +
+
+ +
+
+ +
+
+} \ No newline at end of file diff --git a/src/MusicStore/Views/Account/_ExternalLoginsListPartial.cshtml b/src/MusicStore/Views/Account/_ExternalLoginsListPartial.cshtml new file mode 100644 index 0000000000..8f40061e06 --- /dev/null +++ b/src/MusicStore/Views/Account/_ExternalLoginsListPartial.cshtml @@ -0,0 +1,33 @@ +@using Microsoft.AspNet.Identity; + +

Use another service to log in.

+
+@{ + var loginProviders = Context.HttpContext.GetAuthenticationTypes(); + if (loginProviders.Count() == 0) + { +
+

+ There are no external authentication services configured. See this article + for details on setting up this ASP.NET application to support logging in via external services. +

+
+ } + else + { + string action = Model.Action; + string returnUrl = Model.ReturnUrl; + using (Html.BeginForm(action, "Account", new { ReturnUrl = returnUrl })) + { + @Html.AntiForgeryToken() +
+

+ @foreach (AuthenticationDescription p in loginProviders) + { + + } +

+
+ } + } +} diff --git a/src/MusicStore/Views/Account/_RemoveAccountPartial.cshtml b/src/MusicStore/Views/Account/_RemoveAccountPartial.cshtml new file mode 100644 index 0000000000..5b10a07d92 --- /dev/null +++ b/src/MusicStore/Views/Account/_RemoveAccountPartial.cshtml @@ -0,0 +1,34 @@ +@model ICollection + + @if (Model.Count > 0) + { +

Registered Logins

+ + + @foreach (var account in Model) + { + + + + + } + +
@account.LoginProvider + @if (ViewBag.ShowRemoveButton) + { + using (Html.BeginForm("Disassociate", "Account")) + { + @Html.AntiForgeryToken() +
+ @Html.Hidden("loginProvider", account.LoginProvider) + @Html.Hidden("providerKey", account.ProviderKey) + +
+ } + } + else + { + @:   + } +
+ } \ No newline at end of file diff --git a/src/MusicStore/Views/Account/_SetPasswordPartial.cshtml b/src/MusicStore/Views/Account/_SetPasswordPartial.cshtml new file mode 100644 index 0000000000..ec0173df64 --- /dev/null +++ b/src/MusicStore/Views/Account/_SetPasswordPartial.cshtml @@ -0,0 +1,32 @@ +@model MusicStore.Models.ManageUserViewModel + +

+ You do not have a local username/password for this site. Add a local + account so you can log in without an external login. +

+ +@using (Html.BeginForm("Manage", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" })) +{ + @Html.AntiForgeryToken() + +

Create Local Login

+
+ @Html.ValidationSummary() +
+ @Html.LabelFor(m => m.NewPassword, new { @class = "col-md-2 control-label" }) +
+ @Html.PasswordFor(m => m.NewPassword, new { @class = "form-control" }) +
+
+
+ @Html.LabelFor(m => m.ConfirmPassword, new { @class = "col-md-2 control-label" }) +
+ @Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control" }) +
+
+
+
+ +
+
+} \ No newline at end of file diff --git a/src/MusicStore/Views/Checkout/AddressAndPayment.cshtml b/src/MusicStore/Views/Checkout/AddressAndPayment.cshtml new file mode 100644 index 0000000000..abecefc59c --- /dev/null +++ b/src/MusicStore/Views/Checkout/AddressAndPayment.cshtml @@ -0,0 +1,35 @@ +@model MusicStore.Models.Order + +@{ + //Bug: Need a way to specify the layout page in a single place + Layout = "/Views/Shared/_Layout.cshtml"; + ViewBag.Title = "Address And Payment"; +} + +@section Scripts { + @*@Scripts.Render("~/bundles/jqueryval")*@ +} + +@*@using (Html.BeginForm())*@ +@*{*@ + +

Address And Payment

+
+ Shipping Information + + @*@Html.EditorForModel()*@ +
+
+ Payment +

We're running a promotion: all music is free with the promo code: "FREE"

+ +
+ @*@Html.Label("Promo Code")*@ +
+
+ @Html.TextBox("PromoCode") +
+
+ + +@*}*@ \ No newline at end of file diff --git a/src/MusicStore/Views/Checkout/Complete.cshtml b/src/MusicStore/Views/Checkout/Complete.cshtml new file mode 100644 index 0000000000..fe55e9017c --- /dev/null +++ b/src/MusicStore/Views/Checkout/Complete.cshtml @@ -0,0 +1,16 @@ +@model int + +@{ + //Bug: Need to have a way to specify an application level layout page + Layout = "/Views/Shared/_Layout.cshtml"; + ViewBag.Title = "Checkout Complete"; +} + +

Checkout Complete

+ +

Thanks for your order! Your order number is: @Model

+ +

+ How about shopping for some more music in our + @*@Html.ActionLink("Store", "Index", "Home")*@ +

\ No newline at end of file diff --git a/src/MusicStore/Views/Home/Index.cshtml b/src/MusicStore/Views/Home/Index.cshtml index 341f3af947..3759a6ec75 100644 --- a/src/MusicStore/Views/Home/Index.cshtml +++ b/src/MusicStore/Views/Home/Index.cshtml @@ -1,23 +1,20 @@ @{ + //Bug: Need a way to specify the layout page in a single place Layout = "/Views/Shared/_Layout.cshtml"; ViewBag.Title = "Home Page"; }

MVC Music Store

- @*Bug: Having a ~ in url throws compilation error : https://github.com/aspnet/WebFx/issues/66*@ - +
-
    @foreach (var album in Model) {
  • - @*Bug: Url helpers not implemented yet*@ - @*@album.Title*@ - @album.Title + @album.Title

    @album.Title

  • diff --git a/src/MusicStore/Views/Shared/Components/GenreMenu/Default.cshtml b/src/MusicStore/Views/Shared/Components/GenreMenu/Default.cshtml new file mode 100644 index 0000000000..eccde1ab40 --- /dev/null +++ b/src/MusicStore/Views/Shared/Components/GenreMenu/Default.cshtml @@ -0,0 +1,25 @@ +@model IEnumerable + + \ No newline at end of file diff --git a/src/MusicStore/Views/Shared/Error.cshtml b/src/MusicStore/Views/Shared/Error.cshtml new file mode 100644 index 0000000000..5c392cebb9 --- /dev/null +++ b/src/MusicStore/Views/Shared/Error.cshtml @@ -0,0 +1,8 @@ +@{ + //Bug: Need a way to specify the layout page in a single place + Layout = "/Views/Shared/_Layout.cshtml"; + ViewBag.Title = "Error"; +} + +

    Error.

    +

    An error occurred while processing your request.

    \ No newline at end of file diff --git a/src/MusicStore/Views/Shared/_Layout.cshtml b/src/MusicStore/Views/Shared/_Layout.cshtml index 3518a78ae2..4678bf770f 100644 --- a/src/MusicStore/Views/Shared/_Layout.cshtml +++ b/src/MusicStore/Views/Shared/_Layout.cshtml @@ -8,9 +8,9 @@ @*Bug: No Style and Script helpers yet. Manually including the script files*@ @*@Styles.Render("~/Content/css") @Scripts.Render("~/bundles/modernizr")*@ - - - + + + @*Bug: HtmlHelpers missing*@ - @*
    @@ -51,8 +51,8 @@ @Scripts.Render("~/bundles/bootstrap") @RenderSection("scripts", required: false)*@ - - - + + + \ No newline at end of file diff --git a/src/MusicStore/Views/Shared/_LoginPartial.cshtml b/src/MusicStore/Views/Shared/_LoginPartial.cshtml new file mode 100644 index 0000000000..244c3ed7c2 --- /dev/null +++ b/src/MusicStore/Views/Shared/_LoginPartial.cshtml @@ -0,0 +1,25 @@ +@using Microsoft.AspNet.Identity; + +@if (Context.HttpContext.User != null && Context.HttpContext.User.Identity.IsAuthenticated) +{ + @*using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" })) + { + @Html.AntiForgeryToken() + + + }*@ +} +else +{ + +} \ No newline at end of file diff --git a/src/MusicStore/Views/ShoppingCart/Index.cshtml b/src/MusicStore/Views/ShoppingCart/Index.cshtml index 09c82ce791..33aa1f1a88 100644 --- a/src/MusicStore/Views/ShoppingCart/Index.cshtml +++ b/src/MusicStore/Views/ShoppingCart/Index.cshtml @@ -5,7 +5,7 @@ ViewBag.Title = "Shopping Cart"; } -@*//@section Scripts {*@ +@section Scripts { -@*}*@ +}

    Review your cart: @@ -72,10 +72,10 @@ @item.Count - @* - Remove from cart - *@ + + Remove from cart + } diff --git a/src/MusicStore/Views/Store/Browse.cshtml b/src/MusicStore/Views/Store/Browse.cshtml index c12b81d257..cf176a82a3 100644 --- a/src/MusicStore/Views/Store/Browse.cshtml +++ b/src/MusicStore/Views/Store/Browse.cshtml @@ -8,7 +8,7 @@

    @Model.Name Albums

    - +
      @foreach (var album in Model.Albums) { @@ -16,9 +16,7 @@ @if (!string.IsNullOrEmpty(album.AlbumArtUrl)) { - @*Bug: Url helpers not implemented yet*@ - @*@album.Title*@ - @album.Title + @album.Title }
      @album.Title
      diff --git a/src/MusicStore/Views/Store/Details.cshtml b/src/MusicStore/Views/Store/Details.cshtml index 11c13d6f35..b349aea7b2 100644 --- a/src/MusicStore/Views/Store/Details.cshtml +++ b/src/MusicStore/Views/Store/Details.cshtml @@ -9,9 +9,7 @@

      @Model.Title

      - @*Bug: Url helpers not implemented yet*@ - @*@Model.Title*@ - @Model.Title + @Model.Title

      @@ -25,8 +23,7 @@

      Price: - @*Bug: HTML helpers not implemented yet*@ - @*@Html.DisplayFor(model => model.Price)*@ + @Html.ValueFor(model => model.Price)

      @*Bug: HTML helpers not implemented yet*@ diff --git a/src/MusicStore/Views/Store/GenreMenu.cshtml b/src/MusicStore/Views/Store/GenreMenu.cshtml deleted file mode 100644 index 9786417c2b..0000000000 --- a/src/MusicStore/Views/Store/GenreMenu.cshtml +++ /dev/null @@ -1,21 +0,0 @@ -@*Bug: intellisense changes the case of the type. Need to use a normal text editor to edit this view. -Bug: Child actions not implemented yet*@ -@*@model System.Collections.Generic.IEnumerable*@ - -

      \ No newline at end of file diff --git a/src/MusicStore/Views/StoreManager/Create.cshtml b/src/MusicStore/Views/StoreManager/Create.cshtml index aee77d06be..33d8324127 100644 --- a/src/MusicStore/Views/StoreManager/Create.cshtml +++ b/src/MusicStore/Views/StoreManager/Create.cshtml @@ -1,5 +1,5 @@ @*Bug: Fully dependent on HTML helpers*@ -@model MvcMusicStore.Models.Album +@model MusicStore.Models.Album @{ //Bug: Need to have a way to specify an application level layout page diff --git a/src/MusicStore/Views/StoreManager/Delete.cshtml b/src/MusicStore/Views/StoreManager/Delete.cshtml index 6609a9d0f9..c4d96d3af7 100644 --- a/src/MusicStore/Views/StoreManager/Delete.cshtml +++ b/src/MusicStore/Views/StoreManager/Delete.cshtml @@ -1,5 +1,5 @@ @*Bug: Dependent on Htmlhelpers*@ -@model MvcMusicStore.Models.Album +@model MusicStore.Models.Album @{ //Bug: Need to have a way to specify an application level layout page diff --git a/src/MusicStore/Views/StoreManager/Details.cshtml b/src/MusicStore/Views/StoreManager/Details.cshtml index 07e973cf07..9c32992b23 100644 --- a/src/MusicStore/Views/StoreManager/Details.cshtml +++ b/src/MusicStore/Views/StoreManager/Details.cshtml @@ -1,5 +1,4 @@ -@*Bug: Dependent on Htmlhelpers*@ -@model MvcMusicStore.Models.Album +@model MusicStore.Models.Album @{ //Bug: Need to have a way to specify an application level layout page @@ -14,48 +13,49 @@
      - @Html.DisplayNameFor(model => model.Artist.Name) + @Html.NameFor(model => model.Artist.Name)
      - @Html.DisplayFor(model => model.Artist.Name) + @Html.ValueFor(model => model.Artist.Name)
      - @Html.DisplayNameFor(model => model.Genre.Name) + @Html.NameFor(model => model.Genre.Name)
      - @Html.DisplayFor(model => model.Genre.Name) + @Html.ValueFor(model => model.Genre.Name)
      - @Html.DisplayNameFor(model => model.Title) + @Html.NameFor(model => model.Title)
      - @Html.DisplayFor(model => model.Title) + @Html.ValueFor(model => model.Title)
      - @Html.DisplayNameFor(model => model.Price) + @Html.NameFor(model => model.Price)
      - @Html.DisplayFor(model => model.Price) + @Html.ValueFor(model => model.Price)
      - @Html.DisplayNameFor(model => model.AlbumArtUrl) + @Html.NameFor(model => model.AlbumArtUrl)
      - @Html.DisplayFor(model => model.AlbumArtUrl) + @Html.ValueFor(model => model.AlbumArtUrl)
      -

      - @Html.ActionLink("Edit", "Edit", new { id = Model.AlbumId }) | - @Html.ActionLink("Back to List", "Index") -

      \ No newline at end of file +@*Bug: Need HtmlHelpers*@ +@*

      + @Html.ActionLink("Edit", "Edit", new { id = Model.AlbumId }) | + @Html.ActionLink("Back to List", "Index") +

      *@ \ No newline at end of file diff --git a/src/MusicStore/Views/StoreManager/Edit.cshtml b/src/MusicStore/Views/StoreManager/Edit.cshtml index 24cc9b77c6..0dee9dce8b 100644 --- a/src/MusicStore/Views/StoreManager/Edit.cshtml +++ b/src/MusicStore/Views/StoreManager/Edit.cshtml @@ -1,5 +1,4 @@ -@*Bug: Dependent on Htmlhelpers*@ -@model MvcMusicStore.Models.Album +@model MusicStore.Models.Album @{ //Bug: Need to have a way to specify an application level layout page diff --git a/src/MusicStore/Views/StoreManager/Index.cshtml b/src/MusicStore/Views/StoreManager/Index.cshtml index cd5ba7ffc5..704a610852 100644 --- a/src/MusicStore/Views/StoreManager/Index.cshtml +++ b/src/MusicStore/Views/StoreManager/Index.cshtml @@ -1,5 +1,4 @@ -@*Bug: Dependent on Htmlhelpers*@ -@model IEnumerable +@model IEnumerable @helper Truncate(string input, int length) { @@ -22,21 +21,26 @@

      Index

      - @Html.ActionLink("Create New", "Create") + @*@Html.ActionLink("Create New", "Create")*@

      + @*Bug: Html.NameFor does not contain an overload taking in IEnumerable*@ @@ -45,7 +49,7 @@ { - + *@ }
      - @Html.DisplayNameFor(model => model.Genre.Name) + @*@Html.NameFor(model => model.Genre.Name)*@ + @Html.NameFor(model => model.FirstOrDefault().Genre.Name) - @Html.DisplayNameFor(model => model.Artist.Name) + @*@Html.NameFor(model => model.Artist.Name)*@ + @Html.NameFor(model => model.FirstOrDefault().Artist.Name) - @Html.DisplayNameFor(model => model.Title) + @*@Html.NameFor(model => model.Title)*@ + @Html.NameFor(model => model.FirstOrDefault().Title) - @Html.DisplayNameFor(model => model.Price) + @*@Html.NameFor(model => model.Price)*@ + @Html.NameFor(model => model.FirstOrDefault().Price)
      - @Html.DisplayFor(modelItem => item.Genre.Name) + @Html.ValueFor(modelItem => item.Genre.Name) @Truncate(item.Artist.Name, 25) @@ -54,13 +58,13 @@ @Truncate(item.Title, 25) - @Html.DisplayFor(modelItem => item.Price) + @Html.ValueFor(modelItem => item.Price) + @* @Html.ActionLink("Edit", "Edit", new { id = item.AlbumId }) | @Html.ActionLink("Details", "Details", new { id = item.AlbumId }) | @Html.ActionLink("Delete", "Delete", new { id = item.AlbumId }) -