40 lines
1.3 KiB
C#
40 lines
1.3 KiB
C#
using CMS_CORE_Library.Models;
|
|
using System.Collections.Generic;
|
|
using System.Web.Http;
|
|
using Thermo.Active.Model.DTOModels.ThModules;
|
|
using Thermo.Active.NC;
|
|
using Thermo.Active.Utils;
|
|
|
|
namespace Thermo.Active.Controllers.WebApi
|
|
{
|
|
[RoutePrefix("api/ModBlock")]
|
|
public class ModulesController : ApiController
|
|
{
|
|
/// <summary>
|
|
/// Oggetto adapter condiviso da WebAPI
|
|
/// </summary>
|
|
protected static NcAdapter ncAdapter = new NcAdapter();
|
|
|
|
[Route("current"), HttpGet]
|
|
public IHttpActionResult GetCurrentModules()
|
|
{
|
|
// Try connection
|
|
CmsError libraryError = ncAdapter.Connect();
|
|
if (libraryError.errorCode != 0)
|
|
{
|
|
ThermoActiveLogger.LogError($"NC Not connected! | GetCurrentModules | {libraryError.exception}");
|
|
return InternalServerError();
|
|
}
|
|
|
|
libraryError = ncAdapter.ReadModulesBlock(out Dictionary<int, DTOModulesBlock> currModules);
|
|
if (libraryError.IsError())
|
|
{
|
|
ThermoActiveLogger.LogError($"GetRecipeOverview error | {libraryError.exception}");
|
|
return BadRequest(libraryError.localizationKey);
|
|
}
|
|
|
|
return Ok(currModules);
|
|
}
|
|
|
|
}
|
|
} |