本文整理汇总了C#中ApiAccessPolicy类的典型用法代码示例。如果您正苦于以下问题:C#ApiAccessPolicy类的具体用法?C#ApiAccessPolicy怎么用?C#ApiAccessPolicy使用的例子?这里精选的类代码示例或许可以为您提供帮助。
示例1:Delete
publicvoidDelete(longid)
{
if(id<=0)
{
return;
}
ApiAccessPolicypolicy=newApiAccessPolicy(typeof(MixERP.Net.Entities.Core.Account),"DELETE");
policy.Authorize();
if(!policy.IsAuthorized)
{
thrownewHttpResponseException(HttpStatusCode.Forbidden);
}
try
{
using(Databasedb=newDatabase(Factory.GetConnectionString(),"Npgsql"))
{
db.Delete("core.accounts","account_id",null,id);
}
}
catch
{
thrownewHttpResponseException(HttpStatusCode.InternalServerError);
}
}
原文链接:
http://www.jxszl.com/biancheng/C/556544.html