9166b07813
+ Add ShankApi + Add Family Api
116 lines
4.1 KiB
C#
116 lines
4.1 KiB
C#
using Step.NC;
|
|
using System.Collections.Generic;
|
|
using System.Web.Http;
|
|
using static CMS_CORE_Library.DataStructures;
|
|
|
|
namespace Step.Controllers.WebApi
|
|
{
|
|
[RoutePrefix("api/tool_table")]
|
|
public class ToolTableController : ApiController
|
|
{
|
|
[Route("configuration"), HttpGet]
|
|
public IHttpActionResult GetToolTableConfiguration()
|
|
{
|
|
using (NcHandler ncHandler = new NcHandler())
|
|
{
|
|
ncHandler.Connect();
|
|
CmsError libraryError = ncHandler.GetToolTableConfiguration(out ToolTableConfiguration toolTableConfiguration);
|
|
if (libraryError.IsError())
|
|
if (libraryError.errorCode != CMS_ERROR_CODES.NOT_CONNECTED)
|
|
return BadRequest(libraryError.message);
|
|
|
|
return Ok(toolTableConfiguration);
|
|
}
|
|
}
|
|
|
|
[Route("tools"), HttpGet]
|
|
public IHttpActionResult GetToolTable()
|
|
{
|
|
using (NcHandler ncHandler = new NcHandler())
|
|
{
|
|
ncHandler.Connect();
|
|
CmsError libraryError = ncHandler.GetToolTableData(out List<SiemensToolModel> tools);
|
|
if (libraryError.IsError())
|
|
if (libraryError.errorCode != CMS_ERROR_CODES.NOT_CONNECTED)
|
|
return BadRequest(libraryError.message);
|
|
|
|
return Ok(tools);
|
|
}
|
|
}
|
|
|
|
[Route("shanks"), HttpGet]
|
|
public IHttpActionResult GetShanks()
|
|
{
|
|
using (NcHandler ncHandler = new NcHandler())
|
|
{
|
|
ncHandler.Connect();
|
|
CmsError libraryError = ncHandler.GetShanksData(out List<ShankModel> shanks);
|
|
if (libraryError.IsError())
|
|
if (libraryError.errorCode != CMS_ERROR_CODES.NOT_CONNECTED)
|
|
return BadRequest(libraryError.message);
|
|
|
|
return Ok(shanks);
|
|
}
|
|
}
|
|
|
|
[Route("families"), HttpGet]
|
|
public IHttpActionResult GetFamilies()
|
|
{
|
|
using (NcHandler ncHandler = new NcHandler())
|
|
{
|
|
ncHandler.Connect();
|
|
CmsError libraryError = ncHandler.GetFamiliesData(out List<FamilyModel> families);
|
|
if (libraryError.IsError())
|
|
if (libraryError.errorCode != CMS_ERROR_CODES.NOT_CONNECTED)
|
|
return BadRequest(libraryError.message);
|
|
|
|
return Ok(families);
|
|
}
|
|
}
|
|
|
|
[Route("magazines_positions"), HttpGet]
|
|
public IHttpActionResult GetMagazinesPositions()
|
|
{
|
|
using (NcHandler ncHandler = new NcHandler())
|
|
{
|
|
ncHandler.Connect();
|
|
CmsError libraryError = ncHandler.GetMagazinesPositionsData(out List<MagazinePositionsModel> magazines);
|
|
if (libraryError.IsError())
|
|
if (libraryError.errorCode != CMS_ERROR_CODES.NOT_CONNECTED)
|
|
return BadRequest(libraryError.message);
|
|
|
|
return Ok(magazines);
|
|
}
|
|
}
|
|
|
|
[Route("family"), HttpPost]
|
|
public IHttpActionResult AddFamily([FromBody] dynamic body)
|
|
{
|
|
using (NcHandler ncHandler = new NcHandler())
|
|
{
|
|
ncHandler.Connect();
|
|
CmsError libraryError = ncHandler.AddFamily(body.name.ToString(), out FamilyModel family);
|
|
if (libraryError.IsError())
|
|
if (libraryError.errorCode != CMS_ERROR_CODES.NOT_CONNECTED)
|
|
return BadRequest(libraryError.message);
|
|
|
|
return Ok(family);
|
|
}
|
|
}
|
|
|
|
[Route("shank"), HttpPost]
|
|
public IHttpActionResult AddShank()
|
|
{
|
|
using (NcHandler ncHandler = new NcHandler())
|
|
{
|
|
ncHandler.Connect();
|
|
CmsError libraryError = ncHandler.AddShank(out ShankModel shank);
|
|
if (libraryError.IsError())
|
|
if (libraryError.errorCode != CMS_ERROR_CODES.NOT_CONNECTED)
|
|
return BadRequest(libraryError.message);
|
|
|
|
return Ok(shank);
|
|
}
|
|
}
|
|
}
|
|
} |