public PostsModule(IWindsorContainer container, IPostService postService)
            : base("/Posts")
        {
            _container = container;
            _postService = postService;

            Before += ctx => 
            {
                var session = _container.Resolve<ISession>();
                session.Transaction.Begin();

                return null;
            };

            After += ctx =>
            {
                var session = _container.Resolve<ISession>();
                session.Transaction.Commit();
            };

            Get["/Index"] = parameters => View["Index"];

            Get["/PopulateDatabase"] = parameters =>
            {
                _postService.PopulateDatabase(new PopulateDatabaseCommand());
                return View["PopulateDatabase"];
            };

            Get["/PostsByDescription/{Description}"] = parameters =>
            {
                var request = new GetPostsByDescriptionRequest { Description = parameters.Description };
                var result = _postService.GetPostsByDescription(request);
                return View["PostsByDescription", result.Posts];
            };

            Get["/PostsPerUser"] = parameters =>
            {
                var request = new GetPostsPerUserRequest();
                var result = _postService.GetPostsPerUser(request);
                return View["PostsPerUser", result.PostsPerUser];
            };
        }
 public GetPostsByDescriptionResult GetPostsByDescription(GetPostsByDescriptionRequest request)
 {
     return _dispatcher.Dispatch<GetPostsByDescriptionRequest, GetPostsByDescriptionResult>(request);
 }
 public ActionResult PostsByDescription(string description)
 {
     var request = new GetPostsByDescriptionRequest {Description = description};
     var result = _postService.GetPostsByDescription(request);
     return View(result.Posts);
 }