【发布时间】:2014-04-13 08:17:27
【问题描述】:
我想获得一个三层架构:UI
我的 DAL 是一个“超级”对象,可以处理不同的数据库技术,如 sql server、mysql、ecc..
这就是我认为的业务逻辑层:
/// <summary>
/// Customer entity
/// </summary>
public class Account
{
public String Username;
public String Email;
}
public class AccountService<T>
where T : Account
{
IEntitymanager entityManager;
public AccountService(IEntitymanager entityManager)
{
this.entityManager = entityManager;
}
public void Register(T account,
String confirmPw,
String verificationEmailBody)
{
// Validate parameters...
// Check email uniqueness...
// then write account to db...
if (entityManager.Save<T>(account))
{
// Send verification email whit GUID
}
}
public void Verify(String guid)
{
T account = entityManager.Get<T>(new Parameter("Guid", guid));
// Verify account
}
}
现在我对此有一些疑问:
- 这是业务层的示例还是服务层或 什么?
- 在业务逻辑中验证输入是否正确?
- 在注册方法中,帐户是在哪里创建的?在 UI 层创建是否正确(从输入表单中读取值,创建帐户对象并将其传递给 Register)?
- 我的 BLL 可以通过 entityManager 访问 Db 是否正确?
- 如果我想使用这种 BLL 构建客户端和 Web GUI,我需要其他层吗?
【问题讨论】:
标签: architecture business-logic