上一次我们完成了数据访问层的接口和实现,这次我们按部就班的完成业务层接口及实现,并采用spring.net声明式事务.另外,采用nunit对业务实现进行单元测试.
象petshop框架一样,我们先定义业务层接口,这里只和实体有有耦合.我们拿用户User为例:
IUserManager
using DirectCenter.Model;
namespace DirectCenter.IBLL
{
/// <summary>
/// 用户管理
/// </summary>
public interface IUserManager
{
/// <summary>
/// 创建一个用户(返回包含默认值)
/// </summary>
/// <returns></returns>
User NewUser();
/// <summary>
/// 保存用户
/// </summary>
/// <param name="user">用户实体</param>
/// <returns></returns>
User SaveUser(User user);
/// <summary>
/// 获取用户
/// </summary>
/// <param name="userId">用户ID</param>
/// <returns></returns>
User GetUser(string userId);
/// <summary>
/// 删除用户
/// </summary>
/// <param name="userId">用户ID</param>
/// <returns></returns>
void DeleteUser(string userId);
/// <summary>
/// 更新用户
/// </summary>
/// <param name="user">用户实体</param>
/// <returns></returns>
User UpdateUser(User user);
}
}