【发布时间】:2014-06-20 09:11:17
【问题描述】:
这是我在Web API 中的简单customer 控制器。
public class CustomerController : ApiController
{
BusinessLayer.ICustomerRepositary CustomerRepositary;
public CustomerDTO Get()
{
BusinessLayer.Customer customer = CustomerRepositary.GetCustomers();
// Map customer to customerDTO
return customerDTO;
}
}
我的项目组织:
BusinessLayer --> 模型 (Customer.cs)、CustomerRepository、ICustomerRepository
APILayer --> DTO (CustomerDTO.cs)、CustomerController
我的问题是:
tightly coupling the business layer with the API层是个好主意吗?这里还有其他的模式要实现吗?
当我实现单元测试时,单元测试包含业务层的引用。这个设计正确吗?
【问题讨论】:
标签: c# .net asp.net-mvc design-patterns asp.net-web-api