Last active
December 19, 2015 19:28
-
-
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
This file contains hidden or 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 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; } | |
} |
This file contains hidden or 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 | |
{ | |
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