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 { /// /// Oggetto adapter condiviso da WebAPI /// 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 currModules); if (libraryError.IsError()) { ThermoActiveLogger.LogError($"GetRecipeOverview error | {libraryError.exception}"); return BadRequest(libraryError.localizationKey); } return Ok(currModules); } } }