using GWMS.Data.DTO; using GWMS.UI.Data; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using NLog; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 namespace GWMS.UI.Controllers { [Route("api/PlantData")] [ApiController] public class PlantDataController : ControllerBase { #region Private Fields /// /// Classe per logging /// private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); #endregion Private Fields #region Public Constructors public PlantDataController(GWMSDataService DataService) { _DataService = DataService; Log.Info("Avviata classe PlantDataController"); } #endregion Public Constructors #region Protected Properties protected GWMSDataService _DataService { get; set; } #endregion Protected Properties #region Public Methods // DELETE api/PlantData/5 [HttpDelete("{id}")] public void Delete(int id) { Log.Debug($"PlantData: Chiamata Delete | {id} | nothing 2 do"); } // GET: api/PlantData [HttpGet] public async Task> Get() { Log.Debug("PlantData: Chiamata Get"); // serializzo i dati di PlantDTO dell'impianto richiesto List ListRecords = await _DataService.PlantDtoGetAllAsync(); return ListRecords; } // GET api/PlantData/5 [HttpGet("{id}")] public async Task Get(int id) { Log.Debug($"PlantData: Chiamata Get | id: {id}"); // serializzo i dati di PlantDTO dell'impianto richiesto var ListRecords = await _DataService.PlantDtoGetAllAsync(); //seleziono plant... var SelRecords = ListRecords.Where(X => X.PlantId == id).FirstOrDefault(); return SelRecords; } // POST api/PlantData [HttpPost] public void Post([FromBody] string value) { Log.Debug("PlantData: Chiamata Post | nothing 2 do"); } // PUT api/PlantData/5 [HttpPut("{id}")] public void Put(int id, [FromBody] string value) { Log.Debug("PlantData: Chiamata Put | nothing 2 do"); } #endregion Public Methods } }