diff --git a/src/MusicStore/Components/CartSummaryComponent.cs b/src/MusicStore/Components/CartSummaryComponent.cs index c28d5c6ea7..f467409722 100644 --- a/src/MusicStore/Components/CartSummaryComponent.cs +++ b/src/MusicStore/Components/CartSummaryComponent.cs @@ -10,6 +10,7 @@ namespace MusicStore.Components public class CartSummaryComponent : ViewComponent { private MusicStoreContext db = new MusicStoreContext(); + public async Task InvokeAsync() { var cart = ShoppingCart.GetCart(db, this.Context); @@ -18,9 +19,9 @@ namespace MusicStore.Components .Select(a => a.Album.Title) .OrderBy(x => x); - //Bug: Uncommenting results in compilation error. - //ViewBag.CartCount = cartItems.Count(); - //ViewBag.CartSummary = string.Join("\n", cartItems.Distinct()); + //Bug: Start using ViewBag when that's available in a ViewComponent + ViewData.Add("CartCount", cartItems.Count()); + ViewData.Add("CartSummary", string.Join("\n", cartItems.Distinct())); return View(); } diff --git a/src/MusicStore/Models/ShoppingCart.cs b/src/MusicStore/Models/ShoppingCart.cs index 158cfcf614..3fc4aee707 100644 --- a/src/MusicStore/Models/ShoppingCart.cs +++ b/src/MusicStore/Models/ShoppingCart.cs @@ -90,7 +90,6 @@ namespace MusicStore.Models { _db.CartItems.Remove(cartItem); } - } return itemCount; @@ -105,12 +104,18 @@ namespace MusicStore.Models // TODO [EF] Change to EntitySet.Remove once querying attaches instances _db.ChangeTracker.Entry(cartItem).State = EntityState.Deleted; } - } public List GetCartItems() { - return _db.CartItems.Where(cart => cart.CartId == ShoppingCartId).ToList(); + var cartItems = _db.CartItems.Where(cart => cart.CartId == ShoppingCartId).ToList(); + //TODO: Auto population of the related album data not available until EF feature is lighted up. + foreach (var cartItem in cartItems) + { + cartItem.Album = _db.Albums.Single(a => a.AlbumId == cartItem.AlbumId); + } + + return cartItems; } public int GetCount() diff --git a/src/MusicStore/Views/Shared/Components/CartSummary/Default.cshtml b/src/MusicStore/Views/Shared/Components/CartSummary/Default.cshtml index 5dc45459f2..22ef700292 100644 --- a/src/MusicStore/Views/Shared/Components/CartSummary/Default.cshtml +++ b/src/MusicStore/Views/Shared/Components/CartSummary/Default.cshtml @@ -1,14 +1,9 @@ -@{ - //Bug: Need to have a way to specify an application level layout page - Layout = "/Views/Shared/_Layout.cshtml"; -} - -@if (ViewBag.CartCount > 0) +@if ((int)ViewData["CartCount"] > 0) {
  • - + - @ViewBag.CartCount + @ViewData["CartCount"]
  • } \ No newline at end of file diff --git a/src/MusicStore/Views/Shared/_Layout.cshtml b/src/MusicStore/Views/Shared/_Layout.cshtml index 33d69098fa..8738680ea0 100644 --- a/src/MusicStore/Views/Shared/_Layout.cshtml +++ b/src/MusicStore/Views/Shared/_Layout.cshtml @@ -27,7 +27,7 @@ @await Html.PartialAsync("_LoginPartial") diff --git a/src/MusicStore/fonts/glyphicons-halflings-regular.eot b/src/MusicStore/fonts/glyphicons-halflings-regular.eot new file mode 100644 index 0000000000..87eaa43423 Binary files /dev/null and b/src/MusicStore/fonts/glyphicons-halflings-regular.eot differ diff --git a/src/MusicStore/fonts/glyphicons-halflings-regular.svg b/src/MusicStore/fonts/glyphicons-halflings-regular.svg new file mode 100644 index 0000000000..5fee068549 --- /dev/null +++ b/src/MusicStore/fonts/glyphicons-halflings-regular.svg @@ -0,0 +1,228 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/MusicStore/fonts/glyphicons-halflings-regular.ttf b/src/MusicStore/fonts/glyphicons-halflings-regular.ttf new file mode 100644 index 0000000000..be784dc1d5 Binary files /dev/null and b/src/MusicStore/fonts/glyphicons-halflings-regular.ttf differ diff --git a/src/MusicStore/fonts/glyphicons-halflings-regular.woff b/src/MusicStore/fonts/glyphicons-halflings-regular.woff new file mode 100644 index 0000000000..2cc3e4852a Binary files /dev/null and b/src/MusicStore/fonts/glyphicons-halflings-regular.woff differ