using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using System.Web.Http.Description;
using Learun.Application.Base.SystemModule;
using Learun.Application.TwoDevelopment.ZZDT_EC;
using Learun.Util;
using log4net.Config;
using NPOI.POIFS.Properties;
using Pipelines.Sockets.Unofficial.Arenas;
namespace Learun.Application.Web.AppApi
{
///
/// 平行电缆(By YuXH)(暂时没用)
///
[HandlerApiLogin(FilterMode.Enforce)]
[TokenAuthorize]
public class ParallelCableApiController : WebApiControllerBase
{
#region 信號相關
///
/// 查询
///
///
/// 如果为0或空,则查询所有。
///
[HttpGet]
public IHttpActionResult GetParalleCable(string projId, string cableId = "")
{
List Ids = new List();
if (string.IsNullOrEmpty(cableId) || cableId == "0")
{
cableId = "";
}
else
{
Ids = cableId.Split(',').ToList();
}
var res = new ec_parallel_CableService().GetList(projId, Ids);
return Success(res);
}
///
/// 批量保存(增、改)。传入ec_cable的集合
///
///
///
[HttpPost]
public IHttpActionResult Save(string projId)
{
try
{
var serv = new ec_parallel_CableService();
var asyncContent = Request.Content.ReadAsStringAsync().Result;
var entity = asyncContent.ToObject>();
foreach (var c in entity)
{
foreach (var p in c.parallelCables)
{
var id = p.p_CableId;
serv.SaveEntity(projId, ref id, p);
p.p_CableId = id;
}
}
return Success(entity);
}
catch (Exception e)
{
return Fail(e.Message);
}
}
///
/// 移除某一个平行电缆
///
///
/// 删除多个,以逗号隔开
///
[HttpPost]
public IHttpActionResult Remove(string projId, string pCableIds)
{
try
{
var serv = new ec_parallel_CableService();
var IDs = pCableIds.Split(',');
foreach (var Id in IDs)
{
serv.DeleteEntity(projId, Id);
}
return Success("OK");
}
catch (Exception e)
{
return Fail(e.Message);
}
}
#endregion
}
}