Files
17168ERP/web/App_Code/api/shuwensController.cs
T

81 lines
2.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
/// <summary>
/// shuwensController 的摘要描述
/// </summary
[ezAuthorize]
public class shuwensController: BaseApiController
{
public shuwensController()
{
//
// TODO: 在這裡新增建構函式邏輯
//
}
[HttpPost]
[Route("api/shuwens/GetActShuwen")]
public IHttpActionResult GetActShuwen([FromBody] Model.activity_shuwen temp)
{
var qry = _db.activity_shuwen.AsQueryable();
if (temp.act_num > 0)
{
qry = qry.Where(x => x.act_num == temp.act_num);
}
if (!string.IsNullOrEmpty(temp.shuwen_type))
{
qry = qry.Where(x => x.shuwen_type == temp.shuwen_type);
}
return Ok(new
{
result = "Y",
data = qry.Select(x => new
{
x.act_num,
x.shuwen_type,
x.shuwen_num,
x.contents
}).FirstOrDefault()
});
}
[HttpPost]
[Route("api/shuwens/GetShuwenTemplate")]
public IHttpActionResult GetShuwenTemplate([FromBody] Model.shuwen_temp temp)
{
var qry = _db.shuwen_temp.AsQueryable();
if (temp.num > 0)
{
qry = qry.Where(x => x.num == temp.num);
}
return Ok(new {result="Y", data = qry.Select(x => new
{
x.num,x.shuwen_type,x.name,x.contents
}).FirstOrDefault() });
}
[HttpPost]
[Route("api/shuwens/ListShuwenTemplate")]
public IHttpActionResult ListShuwenTemplate([FromBody] Model.shuwen_temp temp)
{
var qry = _db.shuwen_temp.AsQueryable();
if (temp!=null&& !string.IsNullOrEmpty(temp.shuwen_type ))
{
qry = qry.Where(x => x.shuwen_type == temp.shuwen_type);
}
return Ok(new
{
result = "Y",
data = qry.Select(x => new
{
x.num,
x.shuwen_type,
x.name,
x.contents
}).ToList()
});
}
}