Permalink
Browse files

Update sample to provide a custom tab which shows how a typical tab l…

…ooks
  • Loading branch information...
avanderhoorn committed Jul 17, 2013
1 parent b9107f2 commit 3a65662aeac406f8a6313237310b8da8f205a230
@@ -0,0 +1,28 @@
+using Glimpse.AspNet.Extensibility;
+using Glimpse.AspNet.Extensions;
+using Glimpse.Core.Extensibility;
+using MvcMusicStore.Models;
+
+namespace MvcMusicStore.Framework
+{
+ 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; }
+ }
+ }
+}
@@ -87,6 +87,7 @@
<Compile Include="Controllers\StoreManagerController.cs" />
<Compile Include="Framework\Configuration.cs" />
<Compile Include="Framework\SqlMapper.cs" />
+ <Compile Include="Framework\TabCart.cs" />
<Compile Include="Framework\TabConfiguration.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
@@ -13,4 +13,17 @@ public class Cart
public virtual Album Album { get; set; }
}
+
+ 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 System.DateTime DateCreated { get; set; }
+ public int RecordId { get; set; }
+ public string CartId { get; set; }
+ }
}
@@ -1,8 +1,12 @@
using System;
using System.Collections.Generic;
+using System.Configuration;
+using System.Data.Common;
using System.Linq;
using System.Web;
using System.Web.Mvc;
+using Dapper;
+using MvcMusicStore.Framework;
namespace MvcMusicStore.Models
{
@@ -103,6 +107,19 @@ public List<Cart> GetCartItems()
return storeDB.Carts.Where(cart => cart.CartId == ShoppingCartId).ToList();
}
+ public List<CartItem> GetCartDetials()
+ {
+ var connectionString = ConfigurationManager.ConnectionStrings["MusicStoreEntities"];
+ var factory = DbProviderFactories.GetFactory(connectionString.ProviderName);
+ using (var connection = factory.CreateConnection())
+ {
+ connection.ConnectionString = connectionString.ConnectionString;
+ connection.Open();
+
+ return connection.Query<CartItem>(string.Format("SELECT C.RecordId, C.CartId, C.AlbumId, C.Count, C.DateCreated, A.Title AS AlbumTitle, A.Price AS AlbumPrice, AR.Name AS ArtistName, G.Name AS GenreName FROM Carts C LEFT JOIN Albums A ON C.AlbumId = A.AlbumId LEFT JOIN Artists AR ON A.ArtistId = AR.ArtistId LEFT JOIN Genres G ON A.GenreId = G.GenreId WHERE CartId = '{0}'", ShoppingCartId)).ToList();
+ }
+ }
+
public int GetCount()
{
// Get the count of each item in the cart and sum them up

0 comments on commit 3a65662

Please sign in to comment.