神祖牌位管理模組,掛單模組前端URL添加HTTP_HOST
This commit is contained in:
38
web/App_Code/api/AncestralTabletStatisticsController.cs
Normal file
38
web/App_Code/api/AncestralTabletStatisticsController.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
|
||||
/// <summary>
|
||||
/// AncestralTabletStatisticsController 的摘要描述
|
||||
/// </summary>
|
||||
public class AncestralTabletStatisticsController:ApiController
|
||||
{
|
||||
private Model.ezEntities db = new Model.ezEntities();
|
||||
[HttpGet]
|
||||
[Route("api/ancestraltablet/statistics/positions/availablepositions")]
|
||||
public IHttpActionResult GetAvailablePositions()
|
||||
{
|
||||
var query =
|
||||
from a in db.AncestralTabletArea // 区域表
|
||||
join p in db.AncestralTabletPosition
|
||||
on a.AreaId equals p.AreaId into ap
|
||||
from p in ap.DefaultIfEmpty()
|
||||
join r in db.AncestralTabletRegistrant
|
||||
on p.PositionId equals r.PositionId into pr
|
||||
from r in pr.DefaultIfEmpty()
|
||||
group new { a, p, r } by new { a.AreaId, a.AreaName } into g
|
||||
select new
|
||||
{
|
||||
AreaId = g.Key.AreaId,
|
||||
AreaName = g.Key.AreaName,
|
||||
TotalPositions = g.Count(x => x.p != null), // 总位置数
|
||||
AvailableCount = g.Count(x => x.p != null && x.r == null) // 可用位置数(未登记)
|
||||
};
|
||||
|
||||
var result = query.ToList();
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user