NHibernate 做个小项目来试一下吧 五

写完了数据层,就要写 业务层了,其实对这个小小小项目来说,这两个层完全可以合并在一起,但是为了体现一个N层的理念,我也把它分离出来写了,反正要写的代码也不多

using System;
using System.Collections;

using guestbook.data;
using guestbook.Dal; 


namespace guestbook.BLL
{
    
/// <summary>
    
/// guestbookbll 的摘要说明。
    
/// </summary>

    public class guestbookbll
    
{
        
public void AddGuestBook(guestbooks gb)
        
{
            
if((gb.title.Trim()==string.Empty)||(gb.username.Trim()==string.Empty))
                
return;

            guestbookdal dal
=new guestbookdal();
            
            dal.addGuestBook(gb);
        }


        
public void UpdateGuestBook(guestbooks gb,int Id)
        
{
            
if((gb.title.Trim()==string.Empty)||(gb.username.Trim()==string.Empty))
                
return;
            
            guestbookdal dal
=new guestbookdal();

            dal.updateGuestBook(gb,Id);
        }


        
public void DelGuestBook(guestbooks gb)
        
{

            guestbookdal dal
=new guestbookdal();
            dal.DelGuestBook(gb);
        }


    }

}


using System;
using System.Collections;

using guestbook.data;
using guestbook.Dal; 

namespace guestbook.BLL
{
    
/// <summary>
    
/// usersbll 的摘要说明。
    
/// </summary>

    public class usersbll
    
{
        
public users login(string username,string password)
        
{
            
//简单的业务验证
            if((username.Trim()==string.Empty)||(password.Trim()==string.Empty))
                
return null;
            usersdal dal
=new usersdal();
            users user
=dal.login(username,password);

            
return user;
        }


        
public void UserAdd(users user)
        
{
            
if((user.Name.Trim()==string.Empty)||(user.password.Trim()==string.Empty))
                
return;

            usersdal dal
=new usersdal();
            dal.addUser(user);

        }


    }

}


只是加了一些非常简单的验证,还有在web上不想完成的功能, 在这里也就不加上了,呵呵
编译一下,继续用Nunit 测试,绿色,爽!!!!!!!!!!!!!
posted @ 2004-10-15 11:51 无心之柳.NET 阅读(...) 评论(...) 编辑 收藏