Permalink
Browse files

dump helper, show API responses

  • Loading branch information...
1 parent de7532f commit a72e26c03d8e782c46772a43285c00ff6afa7b04 Tim Iles committed Mar 30, 2012
View
37 Sample.Mvc3/App_Code/Helpers.cshtml
@@ -0,0 +1,37 @@
+@using System.Collections
+@helper Dump(object model)
+ {
+ if (model is IEnumerable)
+ {
+ int item = 0;
+ foreach (var m in (IEnumerable)model)
+ {
+ <h3>
+ Item @(item++)</h3>
+ @Dump(m)
+ }
+ }
+ else
+ {
+ var props = model.GetType().GetProperties();
+ <table>
+ <tr>
+ <th>
+ Property
+ </th>
+ <th>
+ Value
+ </th>
+ </tr>
+ @foreach (var prop in props)
+ {
+ <tr>
+ <td>@prop.Name
+ </td>
+ <td>@prop.GetValue(model, new object[0])
+ </td>
+ </tr>
+ }
+ </table>
+ }
+}
View
44 Sample.Mvc3/Controllers/HomeController.cs
@@ -92,5 +92,49 @@ public ActionResult Index()
return View();
}
+ public ActionResult Merchant()
+ {
+ GoCardless.Environment = GoCardless.Environments.Sandbox;
+ ViewData.Model = GoCardless.Api.GetMerchant(MyMerchantId);
+ return View();
+ }
+
+ public ActionResult Bills()
+ {
+ GoCardless.Environment = GoCardless.Environments.Sandbox;
+ ViewData.Model = GoCardless.Api.GetMerchantBills(MyMerchantId);
+ return View();
+ }
+
+ public ActionResult Subscriptions()
+ {
+ GoCardless.Environment = GoCardless.Environments.Sandbox;
+ ViewData.Model = GoCardless.Api.GetMerchantSubscriptions(MyMerchantId);
+ return View();
+ }
+
+ public ActionResult PreAuthorizations()
+ {
+ GoCardless.Environment = GoCardless.Environments.Sandbox;
+ ViewData.Model = GoCardless.Api.GetMerchantPreAuthorizations(MyMerchantId);
+ return View();
+ }
+
+ public ActionResult Users()
+ {
+ GoCardless.Environment = GoCardless.Environments.Sandbox;
+ ViewData.Model = GoCardless.Api.GetMerchantUsers(MyMerchantId);
+ return View();
+ }
+
+ public ActionResult Cancel()
+ {
+ return View();
+ }
+
+ public ActionResult Success()
+ {
+ return View();
+ }
}
}
View
21 Sample.Mvc3/Sample.Mvc3.csproj
@@ -58,6 +58,9 @@
<Reference Include="System.EnterpriseServices" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Controllers\GoCardlessController.cs">
+ <SubType>Code</SubType>
+ </Compile>
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
@@ -92,6 +95,24 @@
<Name>GoCardlessSdk</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <Content Include="Views\Home\Merchant.cshtml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="Views\Home\Bills.cshtml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="Views\Home\Subscriptions.cshtml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="Views\Home\PreAuthorizations.cshtml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="App_Code\Helpers.cshtml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="Views\Home\Users.cshtml" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
View
8 Sample.Mvc3/Views/Home/Bills.cshtml
@@ -0,0 +1,8 @@
+@model IEnumerable<GoCardlessSdk.Api.BillResponse>
+
+@{
+ ViewBag.Title = "Bills";
+}
+
+<h2>Bills</h2>
+@Helpers.Dump(Model)
View
8 Sample.Mvc3/Views/Home/Merchant.cshtml
@@ -0,0 +1,8 @@
+@model GoCardlessSdk.Api.MerchantResponse
+
+@{
+ ViewBag.Title = "Merchant";
+}
+
+<h2>Merchant</h2>
+@Helpers.Dump(Model)
View
8 Sample.Mvc3/Views/Home/PreAuthorizations.cshtml
@@ -0,0 +1,8 @@
+@model IEnumerable<GoCardlessSdk.Api.PreAuthorizationResponse>
+
+@{
+ ViewBag.Title = "PreAuthorizations";
+}
+
+<h2>PreAuthorizations</h2>
+@Helpers.Dump(Model)
View
7 Sample.Mvc3/Views/Home/Subscriptions.cshtml
@@ -0,0 +1,7 @@
+@model IEnumerable<GoCardlessSdk.Api.SubscriptionResponse>
+@{
+ ViewBag.Title = "Subscriptions";
+}
+<h2>
+ Subscriptions</h2>
+@Helpers.Dump(Model)
View
8 Sample.Mvc3/Views/Home/Users.cshtml
@@ -0,0 +1,8 @@
+@model IEnumerable<GoCardlessSdk.Api.UserResponse>
+
+@{
+ ViewBag.Title = "Users";
+}
+
+<h2>Users</h2>
+@Helpers.Dump(Model)
View
4 Sample.Mvc3/Views/Shared/_Layout.cshtml
@@ -17,7 +17,11 @@
<div id="menucontainer">
<ul id="menu">
<li>@Html.ActionLink("Home", "Index", "Home")</li>
+ <li>@Html.ActionLink("Merchant", "Merchant", "Home")</li>
<li>@Html.ActionLink("Bills", "Bills", "Home")</li>
+ <li>@Html.ActionLink("PreAuthorizations", "PreAuthorizations", "Home")</li>
+ <li>@Html.ActionLink("Subscriptions", "Subscriptions", "Home")</li>
+ <li>@Html.ActionLink("Users", "Users", "Home")</li>
</ul>
</div>
</div>

0 comments on commit a72e26c

Please sign in to comment.