jbogard / MediatR

Simple, unambitious mediator implementation in .NET
Apache License 2.0
11.16k stars 1.18k forks source link

ASP.NET MVC Example #8

Closed martosource closed 9 years ago

martosource commented 10 years ago

Is there a complete example of using MediaR with ASP.NET MVC including the decorator pattern pipeline for validation, authorisation?

jbogard commented 10 years ago

No, but I'm working on it. Looking at converting the MVC sample app to using it from MS.

jenspettersson commented 10 years ago

First: Thanks for a great series of blog posts and a simple, easy to understand Mediator.

I would love to see an example with (domain) event dispatching as well. I'm working on a similar project just to learn the pattern (https://github.com/jenspettersson/Mediocr - partly a shameless clone ;)) where I'm struggling a bit with how to track and dispatch events from domain entities.

I'm using RavenDb and for now I wrapped the session with a... generic repository... that also keeps the requested entities in it's own UoW so I can access them easily later... It doesn't feel... perfect.

martosource commented 9 years ago

Thanks Jimmy.

If you are able to set up and start the conversion of a MVC sample app, I am more than happy to put the work in to complete it.

getuliojr commented 9 years ago

I also could help the sample, but we do need something to follow along, so lets us know when you do have something. Another question regarding your post: http://lostechies.com/jimmybogard/2013/12/19/put-your-controllers-on-a-diet-posts-and-commands/

you said: "So why two methods? Fairly simple – it’s a bit easier to deal with separate pipelines for queries and commands, as the potential extensions for these two pipelines might be different. I also might have different rules applied and so on."

But as far as I checked mediatR, you only have one type to handle and not one for queries and other for commands. Am I wrong ? Or do you mind explaining why going in this path ?

jbogard commented 9 years ago

On the queries/command thing - I just changed my mind. There wasn't any difference between the two, I could control it more easily with an ICommand or IQuery that I define.

getuliojr commented 9 years ago

Thanks for the feedback, I also think your line of thinking is better. It is much easier to deal with side effects than all the code necessary to keep it 100% separating between query and commands.

mreyeros commented 9 years ago

Hey Jimmy, any update on the MVC sample?

jbogard commented 9 years ago

Does the Web API example help at all? It would work for MVC too.

getuliojr commented 9 years ago

I have a complete working version with OWIN + MediatR + Autofac + Web Api 2 and the basic test it went just fine.

jbogard commented 9 years ago

@getuliojr if you're down for it, i'd love a PR that does something similar with what I did for StructureMap. Big ask though, I know

mreyeros commented 9 years ago

That works for me!

On Fri, Jan 23, 2015, 11:04 AM Jimmy Bogard notifications@github.com wrote:

Does the Web API example help at all? It would work for MVC too.

— Reply to this email directly or view it on GitHub https://github.com/jbogard/MediatR/issues/8#issuecomment-71215572.

getuliojr commented 9 years ago

I will prepare a PR and build an example working with this tecnology by next week ok ? Glad to help the community back.

jbogard commented 9 years ago

Awesome!

jbogard commented 9 years ago

Updated Web API to include an MVC sample

vrs-rajkumarbapu commented 9 years ago

Hi jbogard, Thanx for your post here. You concept is good. But I am looking few steps in making an application using mediatr with my MVC EF 6 codefirst with angularjs. It will be much helpfull if you can recommend any posts or website to follow or even your guidance.

vrs-rajkumarbapu commented 9 years ago

I need to know how to run your mediatr application, just was trying to achieve ResourceName method through errors.

zeeshanasgar commented 1 year ago

I am trying to implement CQRS in ASP.NET MVC application But It didn't work can anyone help me how to implement CQRS in MVC.