title: ActionResult selector and design patterns
body: <p>I'd like to create like a fabric of <code>ActionResult</code>'s based on the user choice. </p>
  
  <p>My question is if it could be done in a more generic way or at least improvised somehow?</p>
  
  <p>I just to make sure that it has done well.</p>
  
  <p>Here is my code.</p>
  
  <pre><code>&lt;p&gt;A Partial Control that is initialized on Server-Side&lt;/p&gt;
  @{
      &lt;h2&gt;@ViewBag.InitializeUserControl&lt;/h2&gt;
      Html.RenderAction("ShowGadget",new { actionName = (string)@ViewBag.InitializeUserControl } );      
  }
  
   public class HomeController : Controller
      {
          public ActionResult Index()
          {
              @ViewBag.InitializeUserControl = "InitializeUserControl2"; // IT GOES FROM A DATABASE
              return View(new HomeModel());
          }
  
          public ActionResult ShowGadget(string actionName)
          {
              var gadgetPresenter = new GadgetPresenter();
              return gadgetPresenter.GetActionResult(actionName);
          }
      }
  
  
      public class GadgetPresenter : Controller
      {
          public ActionResult GetActionResult(string actionName)
          {
              if (string.IsNullOrEmpty(actionName))
              {
                  return DefaultUserControl();
              }
              else
              {
                  if (actionName.Equals("InitializeUserControl"))
                  {
                      return InitializeUserControl();
                  }
                  else if (actionName.Equals("InitializeUserControl2"))
                  {
                      return InitializeUserControl2();
                  }
                  else
                      return DefaultUserControl();
              }
          }
  
          public ActionResult InitializeUserControl2()
          {
              ColorModel colorModel = new ColorModel
              {
                  Width = 100,
                  Height = 100,
                  RGBColor = "#FF0000"
              };
  
              return PartialView("UserControls/ColorBlockUserControl2", colorModel);
          }
  
          public ActionResult InitializeUserControl()
          {
              ColorModel colorModel = new ColorModel
              {
                  Width = 200,
                  Height = 200,
                  RGBColor = "#FF0000"
              };
  
              return PartialView("UserControls/ColorBlockUserControl", colorModel);
          }
  
          public ActionResult DefaultUserControl()
          {
              return PartialView("UserControls/DummyControl");
          }
  
      }
  </code></pre>