62,040
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebApplication1.Bll;
using WebApplication1.Model;
namespace WebApplication1
{
/// <summary>
/// Action 的摘要说明
/// </summary>
public class Action : IHttpHandler
{
private TestBll bll;
public Action()
{
bll = new TestBll();
}
public void ProcessRequest(HttpContext context)
{
string action = context.Request["Action"];
switch (action)
{
case "Create":
Create(context);
break;
case "Retrieve":
Retrieve(context);
break;
case "Update":
Update(context);
break;
case "Delete":
Delete(context);
break;
default:
List(context); break;
}
}
#region 增加
private void Create(HttpContext context)
{
}
#endregion
#region 读取
private void Retrieve(HttpContext context)
{
try
{
//判断权限
if(无操作权限)
{
//日志记录
//错误提示
}
//参数获取
int id = Convert.ToInt32(context.Request["Id"]);
//调用Bll层获取对象
TestModel model = bll.GetModelById(id);
if (model == null)//找不到对象
{
//日志记录
//错误提示
}
//数据输出
context.Response.Write(json对象或者其他);
}
catch (Exception ex)
{
//日志记录
//错误提示
}
}
#endregion
#region 更新
private void Update(HttpContext context)
{
}
#endregion
#region 删除
private void Delete(HttpContext context)
{
}
#endregion
public bool IsReusable
{
get
{
return false;
}
}
}
}