Last active
December 19, 2015 21:29
-
-
Save avanderhoorn/6020278 to your computer and use it in GitHub Desktop.
Show the content of a shopping cart style of component you might have written, using a custom layout - Your Code, Your Plugins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TabCart : AspNetTab, ITabLayout | |
{ | |
//UPDATED CODE | |
private static readonly object Layout = TabLayout.Create() | |
.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(); | |
//UPDATED CODE | |
public override string Name | |
{ | |
get { return "Cart"; } | |
} | |
public override object GetData(ITabContext context) | |
{ | |
var httpContext = context.GetHttpContext(); | |
var cart = ShoppingCart.GetCart(httpContext); | |
var items = cart.GetCartDetials(); | |
//UPDATED CODE | |
var root = new | |
{ | |
CartId = ShoppingCart.GetCartId(httpContext), | |
Total = items.Any() ? items.Sum(x => x.AlbumPrice).ToString() : "--", | |
Items = items | |
}; | |
//UPDATED CODE | |
return root; | |
} | |
public override RuntimeEvent ExecuteOn | |
{ | |
get { return RuntimeEvent.EndSessionAccess; } | |
} | |
public object GetLayout() | |
{ | |
return Layout; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Glimpse.AspNet.Extensibility; | |
using Glimpse.AspNet.Extensions; | |
using Glimpse.Core.Extensibility; | |
using Glimpse.Core.Tab.Assist; | |
using MvcMusicStore.Models; | |
namespace MvcMusicStore.Framework | |
{ | |
public class TabCart : AspNetTab, ITabLayout | |
{ | |
//NEW CODE | |
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(); | |
//NEW CODE | |
public override string Name | |
{ | |
get { return "Cart"; } | |
} | |
public override object GetData(ITabContext context) | |
{ | |
var cart = ShoppingCart.GetCart(context.GetHttpContext()); | |
var items = cart.GetCartDetials(); | |
return items; | |
} | |
public override RuntimeEvent ExecuteOn | |
{ | |
get { return RuntimeEvent.EndSessionAccess; } | |
} | |
//NEW CODE | |
public object GetLayout() | |
{ | |
return Layout; | |
} | |
//NEW CODE | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
using Glimpse.AspNet.Extensibility; | |
using Glimpse.AspNet.Extensions; | |
using Glimpse.Core.Extensibility; | |
using Glimpse.Core.Tab.Assist; | |
using MvcMusicStore.Models; | |
namespace MvcMusicStore.Framework | |
{ | |
public class TabCart : AspNetTab, ITabLayout, ILayoutControl | |
{ | |
private static readonly object Layout = TabLayout.Create() | |
.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 | |
{ | |
get { return "Cart"; } | |
} | |
//NEW CODE | |
public bool KeysHeadings | |
{ | |
get { return true; } | |
} | |
//NEW CODE | |
public override object GetData(ITabContext context) | |
{ | |
var httpContext = context.GetHttpContext(); | |
var cart = ShoppingCart.GetCart(httpContext); | |
var items = cart.GetCartDetials(); | |
var root = new | |
{ | |
//UPDATED CODE | |
Details = new { | |
CartId = ShoppingCart.GetCartId(httpContext), | |
Total = items.Any() ? items.Sum(x => x.AlbumPrice).ToString() : "--" | |
}, | |
//UPDATED CODE | |
Items = items | |
}; | |
return root; | |
} | |
public override RuntimeEvent ExecuteOn | |
{ | |
get { return RuntimeEvent.EndSessionAccess; } | |
} | |
public object GetLayout() | |
{ | |
return Layout; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment