Skip to content

Instantly share code, notes, and snippets.

@avanderhoorn
Last active December 19, 2015 19:28
Show Gist options
  • Save avanderhoorn/6006105 to your computer and use it in GitHub Desktop.
Save avanderhoorn/6006105 to your computer and use it in GitHub Desktop.
Show the content of a shopping cart style of component you might have written - Your Code, Your Plugins
public class ShoppingCart
{
//...
public static ShoppingCart GetCart(HttpContextBase context)
{
var cart = new ShoppingCart();
cart.ShoppingCartId = cart.GetCartId(context);
return cart;
}
public string GetCartId(HttpContextBase context)
{
//Pulls cartId from Session
}
public List<CartItem> GetCartDetials()
{
//Pull cart items from Cache
}
//...
}
public class CartItem
{
public string AlbumTitle { get; set; }
public decimal AlbumPrice { get; set; }
public string GenreName { get; set; }
public string ArtistName { get; set; }
public int AlbumId { get; set; }
public int Count { get; set; }
public DateTime DateCreated { get; set; }
public int RecordId { get; set; }
public string CartId { get; set; }
}
public class TabCart : AspNetTab
{
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; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment