using AppData;
using NKC_SDK;
using System.Web.Http;
namespace NKC_WF.Controllers
{
public class BunkController : ApiController
{
///
/// Restituisce il FIRST BUNK da lavorare
///
///
// GET: api/Bunk
[HttpGet]
public ProdBunk Get()
{
ProdBunk answ = null;
try
{
answ = ComLib.prodGetFirstBunk();
}
catch
{ }
return answ;
}
///
/// Ottengo NEXT BUNK
///
///
///
///
// GET: api/GetNext/5
[HttpGet]
public ProdBunk Get(int id, bool showNext)
{
ProdBunk answ = null;
try
{
if (showNext)
{
answ = ComLib.prodGetNextBunk(id);
}
else
{
answ = ComLib.prodGetBunk(id);
}
}
catch
{ }
return answ;
}
/************************************
* METODI PUT
*
* per abilitare è necessario agire sulal conf di IIS:
*
* - modificare il file applicationHost.config che si trova in C:\Windows\System32\inetsrv\config
* - disinstallare webDav oppure commentare le righe
*
*
*
* - aggiungere PUT/DELETE a handler:
*
*
*
**************************************/
///
/// Effettua la chaimata di update
///
///
///
// PUT: api/Bunk/5
[HttpPut]
public void Put(ProdBunk currBunk)
{
// NB. decodifico direttamente come oggetto, vedere qui:
// https://weblog.west-wind.com/posts/2013/dec/13/accepting-raw-request-body-content-with-aspnet-web-api
// https://weblog.west-wind.com/posts/2017/sep/14/accepting-raw-request-body-content-in-aspnet-core-api-controllers
// se non nullo...
if (currBunk != null)
{
foreach (var item in currBunk.SheetList)
{
DataLayer.man.taSHL.updateDate(item.SheetId, item.Printing.DtStart, item.Printing.DtEnd, item.Machining.DtStart, item.Machining.DtEnd, item.Unloading.DtStart, item.Unloading.DtEnd);
}
}
// INVALIDO eventuale valore BUNK in REDIS...
ComLib.resetRedisBunkData();
}
#if false
// POST: api/Bunk
[HttpPost]
public void Post([FromBody]string value)
{
}
// DELETE: api/Bunk/5
[HttpDelete]
public void Delete(int id)
{
}
#endif
}
}