In my ASP.NET MVC code, I like to use controller service classes for my controllers. These service classes contain methods for retrieving viewmodel objects.
Here is an example controller snippet:
public SubscriptionsController(ISubscriptionsControllerService service)
{
_service = service;
}
public ActionResult Index(Guid id)
{
return View("Subscriptions", _service.GetSubscriptionsViewModelOnGet(id));
}
[HttpPost]
public ActionResult Index(SubscriptionsViewModel viewModel)
{
_service.SaveSubscriptions(viewModel);
return View("Subscriptions", _service.GetSubscriptionsViewModelOnPost(viewModel));
}
As you can see, I have a method for retrieving the subscriptions viewmodel on a GET request, as well as the equivalent for a POST request.
The POST method takes in an existing viewmodel object and updates any relevant data e.g. a list of subscription items, that need to be refreshed before passing back to the view.
My question is whether the naming of the methods (GetSubscriptionsViewModelOnGet() and GetSubscriptionsViewModelOnPost()) makes sense. They seem OK to me, but I'm interested in other people's views.