Permalink
Browse files

Added advanced styling for TabCart

  • Loading branch information...
avanderhoorn committed Jul 18, 2013
1 parent 8e88d0e commit e1fb2ca94454d29be9cd6dacf77cafc1d653c593
@@ -1,4 +1,5 @@
-using Glimpse.AspNet.Extensibility;
+using System.Linq;
+using Glimpse.AspNet.Extensibility;
using Glimpse.AspNet.Extensions;
using Glimpse.Core.Extensibility;
using Glimpse.Core.Tab.Assist;
@@ -9,17 +10,16 @@ namespace MvcMusicStore.Framework
public class TabCart : AspNetTab, ITabLayout
{
private static readonly object Layout = TabLayout.Create()
- .Row(r =>
- {
- r.Cell("{{albumTitle}} ({{albumId}})").AsKey().WithTitle("Album (Id)");
- r.Cell("albumPrice").AlignRight().Prefix("$").WidthInPixels(100).WithTitle("Price");
- r.Cell("genreName").WithTitle("Genre");
- r.Cell("artistName").WithTitle("Artist");
- r.Cell("count").Class("mono").WidthInPixels(70).WithTitle("Count");
- r.Cell("dateCreated").WithTitle("Added");
- r.Cell("recordId").WithTitle("Record Id");
- r.Cell("cartId").WithTitle("Cart Id");
- }).Build();
+ .Cell("items", TabLayout.Create().Row(r =>
+ {
+ r.Cell("{{albumTitle}} ({{albumId}})").AsKey().WithTitle("Album (Id)");
+ r.Cell("albumPrice").AlignRight().Prefix("$").WidthInPixels(100).WithTitle("Price");
+ r.Cell("genreName").WithTitle("Genre");
+ r.Cell("artistName").WithTitle("Artist");
+ r.Cell("count").Class("mono").WidthInPixels(70).WithTitle("Count");
+ r.Cell("dateCreated").WithTitle("Added");
+ r.Cell("recordId").WithTitle("Record Id");
+ })).Build();
public override string Name
{
@@ -28,10 +28,19 @@ public override string Name
public override object GetData(ITabContext context)
{
- var cart = ShoppingCart.GetCart(context.GetHttpContext());
+ var httpContext = context.GetHttpContext();
+
+ var cart = ShoppingCart.GetCart(httpContext);
var items = cart.GetCartDetials();
- return items;
+ var root = new
+ {
+ CartId = ShoppingCart.GetCartId(httpContext),
+ Total = items.Any() ? items.Sum(x => x.AlbumPrice).ToString() : "--",
+ Items = items
+ };
+
+ return root;
}
public override RuntimeEvent ExecuteOn
@@ -21,7 +21,7 @@ public partial class ShoppingCart
public static ShoppingCart GetCart(HttpContextBase context)
{
var cart = new ShoppingCart();
- cart.ShoppingCartId = cart.GetCartId(context);
+ cart.ShoppingCartId = GetCartId(context);
return cart;
}
@@ -180,7 +180,7 @@ public int CreateOrder(Order order)
}
// We're using HttpContextBase to allow access to cookies.
- public string GetCartId(HttpContextBase context)
+ public static string GetCartId(HttpContextBase context)
{
if (context.Session[CartSessionKey] == null)
{

0 comments on commit e1fb2ca

Please sign in to comment.