I have a C # MVC application that I break as follows: View -> Controller -> Service -> Repository
I use the subtle controller practice with each view having a unique view model that returns from the corresponding service.
Quick example: View: / NewAppointment / Step1
Its controller will look like this:
public ActionResult Step1()
{
return View(_appointmentService.Step1GetModel() );
}
And the destination service level will look like this:
public Step1Model Step1GetModel()
{
return new Step1Model();
}
Thus, I have several different service levels used in my application, each of which implements a separate interface.
, , . , ?
:
, . , :
, , GetCustomer .
:
private ICustomerService _customerService;
private IAppointmentService _appointmentService;
public ActionResult Step1()
{
var viewModel = _appointmentService.Step1GetModel( _customerService );
return View(viewModel);
}
, .
:
private ICustomerService _customerService;
private IAppointmentService _appointmentService;
public ActionResult Step1()
{
var customer = _customerService.GetCustomer();
var viewModel = _appointmentService.Step1GetModel( customer );
return View(viewModel);
}
, . , . , .
- , ?
~