Saturday, March 26, 2011

FubuMVC - Actions

FubuMVC is shipped with a sample called DarthFubuMVC on GitHub. If you looak at the project, It has some sort of folder structure like what we have in Asp.Net MVC. In there, you can find Actions folder which is similar to Controllers in Asp.Net MVC.

Generally speaking, Fubu is designed based on One Model In - One Model Out. i.e you as developer have to define a type of object as input argument (model) and define another type of object as return value.

The example below explains more in code.

    public class HomeAction
    {
        public HomeViewModel Execute(HomeInputModel model)
        {
            return new HomeViewModel();
        }

    }

     public class HomeInputModel
    {
    }
     public class HomeViewModel
    {
    }

Every Action/Controller class should have Execute method, in order to run. While this method as mentioned above, should have unique object as input and output.

By default, Fubu's routing engine runs HomeAction's execute method when it reaches the url like this:

http://MyPrject.Com/Home.

As stated in previous posts, all suffixes like action,Command, Query... is ignored due to simplicity of Fubu's routing system. Jeremy fully explained the routing system's internals in this post

No comments:

Post a Comment