Skip to content

Instantly share code, notes, and snippets.

@jbogard
Created November 28, 2011 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbogard/1401053 to your computer and use it in GitHub Desktop.
Save jbogard/1401053 to your computer and use it in GitHub Desktop.
Raven Controller
using System;
using System.Web.Mvc;
using Raven.Client;
using TekPub.Profiler.BackOffice.Tasks;
namespace TekPub.Profiler.BackOffice.Controllers
{
public class RavenController : Controller
{
protected IDocumentSession documentSession;
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
documentSession = MvcApplication.DocumentStore.OpenSession();
}
protected override void OnActionExecuted(ActionExecutedContext filterContext)
{
try
{
using(documentSession)
{
if(filterContext.Exception == null)
{
documentSession.SaveChanges();
TaskExecuter.StartExecuting();
}
}
}
finally
{
TaskExecuter.Discard();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment