Files
cms_thermo_active/Step/Controllers/WebApi/NcApiController.cs
T
Lucio Maranta 76b51ea3c5 Refactor
2018-02-20 17:03:03 +01:00

38 lines
1.1 KiB
C#

using Step.Model.DTOModels;
using Step.NC;
using System;
using System.Diagnostics;
using System.Web.Http;
using static CMS_CORE_Library.DataStructures;
using static Step.Utils.Constants;
namespace Step.Controllers.WebApi
{
[RoutePrefix("api/nc")]
public class NcApiController : ApiController
{
[Route("generic_data"), HttpGet]
[WebApiAuthorize(FunctionAccess = "ncData", Action = ACTIONS.READ)]
public IHttpActionResult GetNcGenericData()
{
Stopwatch stop = new Stopwatch();
stop.Start();
try
{
using (NcHandler ncHandler = new NcHandler())
{
ncHandler.Connect();
CmsError libraryError = ncHandler.GetNcGenericData(out DTONcGenericDataModel genericData);
if (libraryError.errorCode != 0)
return Ok(libraryError.message);
return Ok(genericData);
}
}
catch (Exception ex)
{
return InternalServerError(ex);
}
}
}
}