Created
November 28, 2011 16:50
-
-
Save jbogard/1401053 to your computer and use it in GitHub Desktop.
Raven Controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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