vgquotes/Src/VideoGameQuotes.Web/Configuration/DeleteSearchIndexCallHandler.cs
tmont a41335c5ba * improved default browse page
* fixed bug where you couldn't add more categories if none already existed
* added ability to delete quotes
* added call handler to delete the search index when a quote is deleted
2011-03-04 08:20:20 +00:00

31 lines
945 B
C#

using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.InterceptionExtension;
using Portoa.Search;
using VideoGameQuotes.Api;
namespace VideoGameQuotes.Web.Configuration {
/// <summary>
/// Call handler that deletes the search index whenever a quote is deleted
/// </summary>
public class DeleteSearchIndexCallHandler : ICallHandler {
private readonly IUnityContainer container;
public DeleteSearchIndexCallHandler(IUnityContainer container) {
this.container = container;
}
public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext) {
var quoteId = (int)input.Arguments[0];
var returnValue = getNext()(input, getNext);
if (returnValue.Exception != null) {
return returnValue;
}
container.Resolve<ISearchIndexBuilder<Quote, int>>().DeleteIndex(new Quote { Id = quoteId });
return returnValue;
}
public int Order { get; set; }
}
}