首页 新闻 赞助 找找看

我这个应不应该 封装到 BLL 层里面,这些搞得我糊涂了

0
[已解决问题] 解决于 2011-06-26 13:08

这个是 我 ArticleUpd.aspx.cs(文章修改页面 web 层) 里面的,是不是应该封装到 BLL 层里面?

using System;
using System.Collections;
using Lib;
using System.Collections.Generic;

namespace WEB.mgr
{
public partial class UpdArticle : System.Web.UI.Page
{
protected bool Exists = false;
protected MODEL.article Article = null;
protected void Page_Load(object sender, EventArgs e)
{
string ID = Request.QueryString["ID"];
if (StringHelper.isSafeNum(ID))
{
DAL.article article
= new DAL.article();
Article
= article.Get(Convert.ToInt32(ID));

Exists
= true;
string action = Request.QueryString["action"];
if (action == null) action = "";
if (action=="save")
{

string title = Request.Form["title"];
if (title == null) { title = ""; }
string content = Request.Form["content"];
if (content == null) { content = ""; }
string CategoryID = Request.Form["CategoryID"];
if (!Lib.StringHelper.isSafeNum(CategoryID)) { CategoryID = "0"; }

string tags = Request.Form["tags"];
if (tags == null) { tags = ""; }
tags
= tags.Trim().Replace("", ",");
string[] tagArr=tags.Split(',');

MODEL.article artMOD
= new MODEL.article(Convert.ToInt32(ID), Convert.ToInt32(CategoryID), title, content);
BLL.article art
= new BLL.article();
List
<MODEL.tag> tagCollection=new List<MODEL.tag>();

for (int i = 0; i < tagArr.Length; i++)
{
tagCollection.Add(
new MODEL.tag(tagArr[i]));
}
art.Update(artMOD, tagCollection.ToArray());
}
}
}

protected void OutPutCategory()
{
if (Exists)
{
List
<MODEL.category> list = new BLL.category().GetAll();
if (Article.CID==0)
{
Response.Write(
"<option selected=\"selected\" value=\"0\">默认类别</option>\n");
}
for (int i = 0; i < list.Count; i++)
{
if (Article.CID == list[i].ID)
{
Response.Write(
"<option selected=\"selected\" value=\"" + list[i].ID + "\">" + list[i].Name + "</option>\n");
}
else
{
Response.Write(
"<option value=\"" + list[i].ID + "\">" + list[i].Name + "</option>\n");
}
}
}
}

protected string GetArticleTags()
{
return new BLL.article().getTags(Article.ID);
}
}
}

是不是 ,只传递过去这一部分,然后就由BLL 层来处理呢?

string title = Request.Form["title"];
if (title == null) { title = ""; }
string content = Request.Form["content"];
if (content == null) { content = ""; }
string CategoryID = Request.Form["CategoryID"];
if (!Lib.StringHelper.isSafeNum(CategoryID)) { CategoryID = "0"; }

string tags = Request.Form["tags"];
if (tags == null) { tags = ""; }
dbfox的主页 dbfox | 初学一级 | 园豆:2
提问于:2011-05-31 22:18
< >
分享
最佳答案
0

个人意见是放在BLL中,BLL层存在的意义就在于处理业务逻辑,减少显示部分(WEB中为页面,Winform中为窗体)对业务的依赖,所以我认为应该放在BLL层。

artwl | 专家六级 |园豆:16736 | 2011-05-31 23:09
其他回答(3)
0

如果你这段代码能被重用,而且这个项目比较大,那就建议你将这个写到BLL层!这样可以是你在开发时更方便,代码放不放到BLL层,主要看你需不需要!业务逻辑层主要还是看能不能给你提供方便吗,如果不能那还是就舍弃算了!

suber | 园豆:260 (菜鸟二级) | 2011-06-01 10:06
0

我觉得吧 你这个是BLL的东西, 页面最后只是直接调用方法 不做任何事

JCdon | 园豆:2 (初学一级) | 2011-06-02 16:52
0

嗯,你的猜测是正确的

网络技术爱好者 | 园豆:398 (菜鸟二级) | 2011-06-03 16:27
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册