把资料库产色的几个文件提交,汇出挂单功能的数据,状态数据要有才能运行
This commit is contained in:
70
web/App_Code/guadanGuestQueryController.cs
Normal file
70
web/App_Code/guadanGuestQueryController.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Entity;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
|
||||
/// <summary>
|
||||
/// guadanGuestQueryController 的摘要描述
|
||||
/// </summary>
|
||||
public class guadanGuestQueryController: ApiController
|
||||
{
|
||||
private Model.ezEntities _db = new Model.ezEntities();
|
||||
public guadanGuestQueryController()
|
||||
{
|
||||
//
|
||||
// TODO: 在這裡新增建構函式邏輯
|
||||
//
|
||||
}
|
||||
[HttpPost]
|
||||
[Route("api/guadan/guest/query/list")]
|
||||
public async Task<IHttpActionResult> GetList([FromBody] SearchGuestModel search)
|
||||
{
|
||||
var query = _db.GuaDanOrderGuest
|
||||
.Where(guest => guest.StatusCode != "404");
|
||||
if(search.SearchName != null)
|
||||
{
|
||||
query = query.Where(guest => guest.followers.u_name.Contains(search.SearchName));
|
||||
}
|
||||
var data = await query.ToListAsync();
|
||||
var data1 = data.Select(a => new
|
||||
{
|
||||
name = a.followers != null ? a.followers.u_name : null,
|
||||
checkindate = a.CheckInAt,
|
||||
checkoutdate = a.CheckOutAt,
|
||||
guadanorderno = a.GuaDanOrderNo,
|
||||
roomName = GetRoomAndBedString(a.RegionRoomBed),
|
||||
}).ToList();
|
||||
return Ok(new
|
||||
{
|
||||
items = data1,
|
||||
total = data1.Count(),
|
||||
});
|
||||
|
||||
}
|
||||
public string GetRoomAndBedString(RegionRoomBed bed)
|
||||
{
|
||||
if (bed == null || bed.Room == null) return "";
|
||||
var room = bed.Room;
|
||||
var region = room.Region;
|
||||
var name = room.Name + "/" + bed.Name;
|
||||
if(region != null)
|
||||
{
|
||||
name = region.Name + "/" + name;
|
||||
}
|
||||
var parentRegion = region.Region2;
|
||||
while (parentRegion != null)
|
||||
{
|
||||
name = parentRegion.Name + "/" + name;
|
||||
parentRegion = parentRegion.Region2;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
public class SearchGuestModel
|
||||
{
|
||||
public string SearchName = null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user