Your question is a bit complicated because what one developer means by a service is something else to another.
So how do we continue?
Well we know it is the responsibility of the Controller to mediate between the View and the ViewModel.
- Mapping from the request to the ViewModel
- Choosing the appropriate View
- And delivering the ViewModel to the View
Keeping in mind that one ViewModel to one View is generally a good practice.
So what about your Domain model?
Well it's best to keep that seperate don't allow it to leak into your controller, this is to prevent any sort of UI specific information from accidentily making its way onto your Domain model.
Personally I practise the following, I have a slim layer (call it a manager or service) that returns a ViewModel, and receives a ViewModel when talking to the controller. But when talking to my internals talks with my Domain model.
So Controller -> Manager -> Service
Manager maps between Domain model and ViewModel.
For example:
public class MemberManager
{
public MemberService MemberService {get;set;}
public MemberViewModel GetMember(int id)
{
var domainModel = MemberService.GetMember(id);
return new MemberViewModel { FullName = domainModel.FullName };
}
public bool UpdateMember(MemberViewModel viewModel)
{
MemberService.Update(new MemberDomainModel { Id = viewModel.Id, FullName = viewModel.FullName });
return true; // all good.
}
}
And your controller.
public class MemberController
{
public MemberManager MemberManager {get;set;}
public ActionResult View(int id)
{
var viewModel = MemberManager.Get(id);
return View(viewModel);
}
}