Skip to content

Instantly share code, notes, and snippets.

View Boggin's full-sized avatar
💭
bleep bloop blorp

Richard Bogle Boggin

💭
bleep bloop blorp
View GitHub Profile
@Boggin
Boggin / ApiAuthorizeAttribute.cs
Created October 17, 2013 15:46
MS Web API Authorize Attribute with Ninject 3.0
namespace Demo.WebMvc4.Infrastructure
{
using System.Web.Http;
public class ApiAuthorizeAttribute : AuthorizeAttribute
{
public Role Permission { get; set; }
// Note: Ninject currently doesn't support filter binding in Web API so this is a workaround.
protected AuthorizationService AuthorizationService
@Boggin
Boggin / IssueByNameSpecification.cs
Created October 15, 2013 16:08
Specification pattern for repository.
namespace Demo.Repository.Specifications
{
public class IssueByNameSpecification : Specification<Issue>
{
private readonly string key;
public IssueByNameSpecification(string key)
{
this.key = key;
}
@Boggin
Boggin / ApplicationContext.cs
Created October 15, 2013 16:00
Repository pattern infrastructure (with FrameLog auditing).
namespace Demo.Repository.Infrastructure
{
public class ApplicationContext : DbContext
{
public readonly FrameLogModule<ChangeSet, Person> Logger;
public ApplicationContext() : base("name=Demo")
{
Configuration.ProxyCreationEnabled = false;
Database.Initialize(true);
@Boggin
Boggin / Country.cs
Created October 15, 2013 15:48
Lookup tables for code-first Entity Framework (with auditing by FrameLog).
namespace Demo.Repository.Models
{
public class Country : Lookup
{
/// <summary>
/// Gets or sets the issues that link to this.
/// </summary>
/// <remarks>This may be referenced by many issues.</remarks>
public ICollection<Issue> Issues { get; set; }
}
@Boggin
Boggin / EmailService.cs
Created October 15, 2013 15:26
Notification service with email as an example.
namespace Demo.Notification
{
using System.Net.Mail;
public class EmailService : IEmailService
{
public void Notify(NotificationDto notification)
{
var msg = new MailMessage
{
namespace Demo.Ldap.Configuration
{
public LdapConfig(bool enabled, string user, string password, string domain)
{
this.Enabled = enabled;
this.User = user;
this.Password = password;
this.Domain = domain;
}
@Boggin
Boggin / WebFormMvcUtil.cs
Created October 25, 2012 08:09 — forked from SimonRice/RenderActionPartial.spark
Utility class to render MVC Partials & Actions in WebForms (or server side controls).
namespace Website
{
using System.IO;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
public class WebFormMvcUtil
{
private static HtmlHelper html;