Using ViewBag in a view component instead of ViewData.
This commit is contained in:
parent
eeb9326101
commit
24293783f5
|
|
@ -19,9 +19,8 @@ namespace MusicStore.Components
|
||||||
.Select(a => a.Album.Title)
|
.Select(a => a.Album.Title)
|
||||||
.OrderBy(x => x);
|
.OrderBy(x => x);
|
||||||
|
|
||||||
//Bug: Start using ViewBag when that's available in a ViewComponent
|
ViewBag.CartCount = cartItems.Count();
|
||||||
ViewData.Add("CartCount", cartItems.Count());
|
ViewBag.CartSummary = string.Join("\n", cartItems.Distinct());
|
||||||
ViewData.Add("CartSummary", string.Join("\n", cartItems.Distinct()));
|
|
||||||
|
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
@if ((int)ViewData["CartCount"] > 0)
|
@if (ViewBag.CartCount > 0)
|
||||||
{
|
{
|
||||||
<li>
|
<li>
|
||||||
<a href="@Url.Action("Index", "ShoppingCart")" title="@ViewData["CartSummary"]">
|
<a href="@Url.Action("Index", "ShoppingCart")" title="@ViewBag.CartSummary">
|
||||||
<span class="glyphicon glyphicon glyphicon-shopping-cart"></span>
|
<span class="glyphicon glyphicon glyphicon-shopping-cart"></span>
|
||||||
@ViewData["CartCount"]
|
@ViewBag.CartCount
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue