SHARE
TWEET

Untitled

a guest Aug 17th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static class ViewModelCaller<TController> where TController : Controller
  2.     {
  3.         public static ViewResult FromVm<TVm>() where TVm : ViewModelEx
  4.         {
  5.             var viewModelType = typeof(TVm);
  6.             var controllerType = typeof(TController);
  7.             var result = Controller.Action(controllerType.Name, viewModelType.Name).Result as ViewResult;
  8.             return result;
  9.         }
  10.  
  11.         public static ViewResult FromVm<TVm, TC>(object model) where TVm : ViewModelEx where TC : Controller
  12.         {
  13.             var type = typeof(TVm);
  14.             var controllerType = typeof(TController);
  15.             var result = Controller.Action(controllerType.Name, type.Name, new { model }).Result as ViewResult;
  16.             return result;
  17.         }
  18.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top