www.un.org/Depts/DGACM/index_french.htm
鉴于客户分类的开始程度如下:
public class Customer : KeyedObject
{
public Customer(int customerId)
{
_customerRepository.Load(this);
}
private ICustomerRepository _customerRepository = IoC.Resolve(..);
private ICustomerTypeRepository = _customerTypeRepository = IoC.Resolve(..);
public virtual string CustomerName {get;set;}
public virtual int CustomerTypeId [get;set;}
public virtual string CustomerType
{
get
{
return _customerTypeRepository.Get(CustomerTypeId);
}
}
}
客户 类型以价值物体表示:
public class CustomerType : ValueObject
{
public virtual int CustomerTypeId {get;set;}
public virtual string Description {get;set;}
}
当我有客户物体时,这完全是好的。 然而,当我想要在我的MVC中安置一名DonList。 我认为,我对如何正确从ICustomerTypeRepostory中获取客户价值清单的概念进行了斗争。
<编码>ICustomerTypeRepository 非常简单:
public interface ICustomerTypeRepository
{
public CustomerType Get(int customerTypeId);
public IEnumerable<CustomerType> GetList();
}
基本上,我希望能够打电话<代码>。 然而,我认为最好把DAL(保存人)的层面与控制者分开。 现在,我是否刚刚克服重复的问题?
这正是我的控制者目前的状况:
public class CustomerController : ControllerBase
{
private ICustomerTypeRepository _customerTypeRepository = IoC.Resolve(..);
public ActionResult Index()
{
Customer customer = new Customer(customerId);
IEnumerable<CustomerType> customerTypeList =
_customerTypeRepository.GetList();
CustomerFormModel model = new CustomerFormModel(customer);
model.AddCustomerTypes(customerTypeList );
}
}
这对我来说似乎是错的,因为我在主计长和客户中盘点。 在我看来,客户Type的进入层应该eg然.。 页: 1
public class CustomerType : ValueObject
{
// ... Previous Code
private static ICustomerTypeRepository _customerTypeRepository = IoC.Resolve(..);
public static IEnumerable<CustomerType> GetList()
{
_customerTypeRepository.GetList();
}
}
因此,这是我CustomerController
?