Skip to content

Instantly share code, notes, and snippets.

View tawman's full-sized avatar

Todd A. Wood tawman

View GitHub Profile
@tawman
tawman / StructureMapFilterProvider.cs
Created February 20, 2012 19:08
Glimpse Issue 146 Sample Code of Helper used to setup StructureMap for FilterAttribute Injection
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using StructureMap;
namespace Sample.Web.Helpers
{
public class StructureMapFilterProvider : FilterAttributeFilterProvider
{
public StructureMapFilterProvider(IContainer container)
@tawman
tawman / Repository.cs
Created February 19, 2012 02:35
PetaPocoPage Repository method to handle the PetaPoco Page<T> query based on the DataTables request object
using System.Collections.Generic;
using PetaPoco;
using PetaPocoPage.Models;
namespace PetaPocoPage.Services
{
public class Repository
{
private readonly Database _database = new Database("PetaPocoPageDb");
@tawman
tawman / DataTableFormat.cs
Created February 19, 2012 02:18
PetaPocoPage Helper to format the JSON page response to DataTables
using System.Globalization;
using System.Linq;
using PetaPoco;
using PetaPocoPage.Models;
namespace PetaPocoPage.Helpers
{
public class DataTablesFormat
{
public static object PageResponse(DataTablesPageRequest pageRequest, Page<Customer> report)
@tawman
tawman / HomeController.cs
Created February 19, 2012 02:15
PetaPocoPage Home Controller made simple with IModelBinder and Response Helper
using System.Web.Mvc;
using PetaPocoPage.Helpers;
using PetaPocoPage.Models;
using PetaPocoPage.Services;
namespace PetaPocoPage.Controllers
{
public class HomeController : Controller
{
private readonly Repository _repository = new Repository();
@tawman
tawman / DataTableModelBinder.cs
Last active September 30, 2015 20:58
PetaPocoPage View IModelBinder to map the DataTable page request into a simple request object
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PetaPocoPage.Models;
namespace PetaPocoPage.Helpers
{
public class DataTablesModelBinder : IModelBinder
@tawman
tawman / Index.cshtml
Created February 19, 2012 01:51
PetaPocoPage View with a Table and DataTables Configuration
@{
ViewBag.Title = "Server-Side Paging with PetaPoco DataTables";
}
<table id="customers" class="table table-striped table-condensed">
<thead>
<tr>
<th style='width: 4%'>Id</th>
<th>Last</th>
<th>First</th>
@tawman
tawman / HomeController.cs
Created February 12, 2012 03:58
An example ASP.NET MVC3 Controller wired up with a DoddleReport ReportResult Action
using System.Web.Mvc;
using DoddleReport;
using DoddleReport.Web;
using PetaPocoPivot.Services;
namespace PetaPocoPivot.Controllers
{
public class HomeController : Controller
{
private readonly IRepository _repository = new Repository();
@tawman
tawman / Repository.cs
Created February 12, 2012 03:47
PetaPoco returning a PIVOT query as an IEnumerable<dynamic>
using System.Collections.Generic;
using PetaPoco;
namespace PetaPocoPivot.Services
{
public class Repository : IRepository
{
private readonly Database _database = new Database("AdventureWorks");
public IEnumerable<dynamic> GetEmployeeReport()
@tawman
tawman / DynamicReportSource.cs
Created February 10, 2012 17:43
DynamicReportSource Null Object Reference Fix
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using DoddleReport;
namespace Hasc.Web.Helpers
{
public static class DynamicReportSourceExtensions
{
public static IReportSource ToReportSource(this IEnumerable<dynamic> source)
@tawman
tawman / DynamicReportSource.cs
Created February 9, 2012 23:00
DoodleReport Dynamic Report Source Extensions ToReportSource() for IEnumerable<dynamic>
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace DoddleReport
{
public static class DynamicReportSourceExtensions
{
public static IReportSource ToReportSource(this IEnumerable<dynamic> source)
{