Permalink
Browse files

Update sample to provide a custom tab to show configuration setup

  • Loading branch information...
avanderhoorn committed Jul 12, 2013
1 parent 04584d0 commit 4639363cff28f4f1d73392bb4198e4ee4d2ef130
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace MvcMusicStore.Framework
+{
+ public static class Configuration
+ {
+ public static ConfigurationModel Current { get; set; }
+ }
+
+ public class ConfigurationModel
+ {
+ public string Currency { get; set; }
+
+ public double TaxRate { get; set; }
+
+ public int DefaultCategory { get; set; }
+
+ public double MarkupRate { get; set; }
+ }
+}
@@ -0,0 +1,21 @@
+using Glimpse.AspNet.Extensibility;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace MvcMusicStore.Framework
+{
+ public class TabConfiguration : AspNetTab
+ {
+ public override string Name
+ {
+ get { return "Setup"; }
+ }
+
+ public override object GetData(Glimpse.Core.Extensibility.ITabContext context)
+ {
+ return MvcMusicStore.Framework.Configuration.Current;
+ }
+ }
+}
@@ -85,7 +85,9 @@
<Compile Include="Controllers\ShoppingCartController.cs" />
<Compile Include="Controllers\StoreController.cs" />
<Compile Include="Controllers\StoreManagerController.cs" />
+ <Compile Include="Framework\Configuration.cs" />
<Compile Include="Framework\SqlMapper.cs" />
+ <Compile Include="Framework\TabConfiguration.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
@@ -1,9 +1,13 @@
-using System;
+using MvcMusicStore.Framework;
+using System;
using System.Collections.Generic;
+using System.Configuration;
+using System.Data.Common;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
+using Dapper;
namespace MvcMusicStore
{
@@ -60,6 +64,19 @@ public static void RegisterRoutes(RouteCollection routes)
);
}
+ private void LoadConfiguration()
+ {
+ var connectionString = ConfigurationManager.ConnectionStrings["MusicStoreEntities"];
+ var factory = DbProviderFactories.GetFactory(connectionString.ProviderName);
+ using (var connection = factory.CreateConnection())
+ {
+ connection.ConnectionString = connectionString.ConnectionString;
+ connection.Open();
+
+ MvcMusicStore.Framework.Configuration.Current = connection.Query<ConfigurationModel>("SELECT * FROM Configuration").First();
+ }
+ }
+
protected void Application_Start()
{
System.Data.Entity.Database.SetInitializer(new MvcMusicStore.Models.SampleData());
@@ -68,6 +85,7 @@ protected void Application_Start()
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
+ LoadConfiguration();
}
}
}
@@ -20,9 +20,7 @@
<add key="webpages:Version" value="1.0.0.0" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
- <add key="GlimpseVersionCheckAPIDomain" value="localhost:61158"/>
- <add key="hudPageRequestTime" value="600"/>
- <add key="hudPageNetworkTime" value="10"/>
+ <add key="GlimpseVersionCheckAPIDomain" value="localhost:61158"/>
</appSettings>
<system.web>
<trace writeToDiagnosticsTrace="true" enabled="true" pageOutput="false"/>

0 comments on commit 4639363

Please sign in to comment.