diff --git a/src/MusicStore/Controllers/StoreManagerController.cs b/src/MusicStore/Controllers/StoreManagerController.cs index 4b9624cb97..2f58e695e0 100644 --- a/src/MusicStore/Controllers/StoreManagerController.cs +++ b/src/MusicStore/Controllers/StoreManagerController.cs @@ -1,5 +1,6 @@ using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc.ModelBinding; +using Microsoft.AspNet.Mvc.Rendering; using Microsoft.Data.Entity; using MusicStore.Models; using System.Linq; @@ -54,8 +55,8 @@ namespace MusicStore.Controllers public IActionResult Create() { - //ViewBag.GenreId = new SelectList(db.Genres, "GenreId", "Name"); - //ViewBag.ArtistId = new SelectList(db.Artists, "ArtistId", "Name"); + ViewBag.GenreId = new SelectList(db.Genres, "GenreId", "Name"); + ViewBag.ArtistId = new SelectList(db.Artists, "ArtistId", "Name"); return View(); } @@ -70,11 +71,11 @@ namespace MusicStore.Controllers db.SaveChanges(); //Bug: RedirectToAction() not available //return RedirectToAction("Index"); - return View(); + return Redirect("/"); } - //ViewBag.GenreId = new SelectList(db.Genres, "GenreId", "Name", album.GenreId); - //ViewBag.ArtistId = new SelectList(db.Artists, "ArtistId", "Name", album.ArtistId); + ViewBag.GenreId = new SelectList(db.Genres, "GenreId", "Name", album.GenreId); + ViewBag.ArtistId = new SelectList(db.Artists, "ArtistId", "Name", album.ArtistId); return View(album); } @@ -91,8 +92,8 @@ namespace MusicStore.Controllers //return HttpNotFound(); return new HttpStatusCodeResult(404); } - //ViewBag.GenreId = new SelectList(db.Genres, "GenreId", "Name", album.GenreId); - //ViewBag.ArtistId = new SelectList(db.Artists, "ArtistId", "Name", album.ArtistId); + ViewBag.GenreId = new SelectList(db.Genres, "GenreId", "Name", album.GenreId); + ViewBag.ArtistId = new SelectList(db.Artists, "ArtistId", "Name", album.ArtistId); return View(album); } @@ -107,10 +108,10 @@ namespace MusicStore.Controllers db.SaveChanges(); //Bug: Missing RedirectToAction helper //return RedirectToAction("Index"); - return View(); + return Redirect("/"); } - //ViewBag.GenreId = new SelectList(db.Genres, "GenreId", "Name", album.GenreId); - //ViewBag.ArtistId = new SelectList(db.Artists, "ArtistId", "Name", album.ArtistId); + ViewBag.GenreId = new SelectList(db.Genres, "GenreId", "Name", album.GenreId); + ViewBag.ArtistId = new SelectList(db.Artists, "ArtistId", "Name", album.ArtistId); return View(album); } @@ -140,8 +141,7 @@ namespace MusicStore.Controllers db.SaveChanges(); //Bug: Missing helper //return RedirectToAction("Index"); - - return View(); + return Redirect("/"); } //Bug: Can't dispose db. diff --git a/src/MusicStore/Views/StoreManager/Create.cshtml b/src/MusicStore/Views/StoreManager/Create.cshtml index 27f45c304f..1ecd5edeb0 100644 --- a/src/MusicStore/Views/StoreManager/Create.cshtml +++ b/src/MusicStore/Views/StoreManager/Create.cshtml @@ -11,7 +11,7 @@ @using (Html.BeginForm()) { - @Html.AntiForgeryToken() + @*@Html.AntiForgeryToken()*@

Album

@@ -19,42 +19,47 @@ @Html.ValidationSummary(true)
- @Html.LabelFor(model => model.GenreId, "GenreId", new { @class = "control-label col-md-2" }) + @*@Html.LabelFor(model => model.GenreId, "GenreId", new { @class = "control-label col-md-2" })*@ +
@Html.DropDownList("GenreId", String.Empty) - @Html.ValidationMessageFor(model => model.GenreId) + @*@Html.ValidationMessageFor(model => model.GenreId)*@
- @Html.LabelFor(model => model.ArtistId, "ArtistId", new { @class = "control-label col-md-2" }) + @*@Html.LabelFor(model => model.ArtistId, "ArtistId", new { @class = "control-label col-md-2" })*@ +
@Html.DropDownList("ArtistId", String.Empty) - @Html.ValidationMessageFor(model => model.ArtistId) + @*@Html.ValidationMessageFor(model => model.ArtistId)*@
- @Html.LabelFor(model => model.Title, new { @class = "control-label col-md-2" }) + @*@Html.LabelFor(model => model.Title, new { @class = "control-label col-md-2" })*@ +
- @Html.EditorFor(model => model.Title) - @Html.ValidationMessageFor(model => model.Title) + @*@Html.EditorFor(model => model.Title)*@ + @*@Html.ValidationMessageFor(model => model.Title)*@
- @Html.LabelFor(model => model.Price, new { @class = "control-label col-md-2" }) + @*@Html.LabelFor(model => model.Price, new { @class = "control-label col-md-2" })*@ +
- @Html.EditorFor(model => model.Price) - @Html.ValidationMessageFor(model => model.Price) + @*@Html.EditorFor(model => model.Price)*@ + @*@Html.ValidationMessageFor(model => model.Price)*@
- @Html.LabelFor(model => model.AlbumArtUrl, new { @class = "control-label col-md-2" }) + @*@Html.LabelFor(model => model.AlbumArtUrl, new { @class = "control-label col-md-2" })*@ +
- @Html.EditorFor(model => model.AlbumArtUrl) - @Html.ValidationMessageFor(model => model.AlbumArtUrl) + @*@Html.EditorFor(model => model.AlbumArtUrl)*@ + @*@Html.ValidationMessageFor(model => model.AlbumArtUrl)*@
diff --git a/src/MusicStore/Views/StoreManager/Edit.cshtml b/src/MusicStore/Views/StoreManager/Edit.cshtml index 97b5281ba2..3b0c1a4ba8 100644 --- a/src/MusicStore/Views/StoreManager/Edit.cshtml +++ b/src/MusicStore/Views/StoreManager/Edit.cshtml @@ -10,7 +10,7 @@ @using (Html.BeginForm()) { - @Html.AntiForgeryToken() + @*@Html.AntiForgeryToken()*@

Album

@@ -19,42 +19,47 @@ @Html.HiddenFor(model => model.AlbumId)
- @Html.LabelFor(model => model.GenreId, "GenreId", new { @class = "control-label col-md-2" }) + @*@Html.LabelFor(model => model.GenreId, "GenreId", new { @class = "control-label col-md-2" })*@ +
@Html.DropDownList("GenreId", String.Empty) - @Html.ValidationMessageFor(model => model.GenreId) + @*@Html.ValidationMessageFor(model => model.GenreId)*@
- @Html.LabelFor(model => model.ArtistId, "ArtistId", new { @class = "control-label col-md-2" }) + @*@Html.LabelFor(model => model.ArtistId, "ArtistId", new { @class = "control-label col-md-2" })*@ +
@Html.DropDownList("ArtistId", String.Empty) - @Html.ValidationMessageFor(model => model.ArtistId) + @*@Html.ValidationMessageFor(model => model.ArtistId)*@
- @Html.LabelFor(model => model.Title, new { @class = "control-label col-md-2" }) + @*@Html.LabelFor(model => model.Title, new { @class = "control-label col-md-2" })*@ +
- @Html.EditorFor(model => model.Title) - @Html.ValidationMessageFor(model => model.Title) + @*@Html.EditorFor(model => model.Title)*@ + @*@Html.ValidationMessageFor(model => model.Title)*@
- @Html.LabelFor(model => model.Price, new { @class = "control-label col-md-2" }) + @*@Html.LabelFor(model => model.Price, new { @class = "control-label col-md-2" })*@ +
- @Html.EditorFor(model => model.Price) - @Html.ValidationMessageFor(model => model.Price) + @*@Html.EditorFor(model => model.Price)*@ + @*@Html.ValidationMessageFor(model => model.Price)*@
- @Html.LabelFor(model => model.AlbumArtUrl, new { @class = "control-label col-md-2" }) + @*@Html.LabelFor(model => model.AlbumArtUrl, new { @class = "control-label col-md-2" })*@ +
- @Html.EditorFor(model => model.AlbumArtUrl) - @Html.ValidationMessageFor(model => model.AlbumArtUrl) + @*@Html.EditorFor(model => model.AlbumArtUrl)*@ + @*@Html.ValidationMessageFor(model => model.AlbumArtUrl)*@