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)
|
||||
.OrderBy(x => x);
|
||||
|
||||
//Bug: Start using ViewBag when that's available in a ViewComponent
|
||||
ViewData.Add("CartCount", cartItems.Count());
|
||||
ViewData.Add("CartSummary", string.Join("\n", cartItems.Distinct()));
|
||||
ViewBag.CartCount = cartItems.Count();
|
||||
ViewBag.CartSummary = string.Join("\n", cartItems.Distinct());
|
||||
|
||||
return View();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
@if ((int)ViewData["CartCount"] > 0)
|
||||
@if (ViewBag.CartCount > 0)
|
||||
{
|
||||
<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>
|
||||
@ViewData["CartCount"]
|
||||
@ViewBag.CartCount
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
Loading…
Reference in New Issue