Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement