Files
gwms/GWMS.UI/Controllers/PlantDataController.cs
Samuele Locatelli 4fda312aac Avanzamento telemetria:
- altri metodi tracciati
- modifica json x prod
- aggiunta Async vari
2026-03-03 18:57:46 +01:00

91 lines
2.5 KiB
C#

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
/// <summary>
/// Classe per logging
/// </summary>
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<List<PlantDTO>> Get()
{
Log.Debug("PlantData: Chiamata Get");
// serializzo i dati di PlantDTO dell'impianto richiesto
List<PlantDTO> ListRecords = await _DataService.PlantDtoGetAllAsync();
return ListRecords;
}
// GET api/PlantData/5
[HttpGet("{id}")]
public async Task<PlantDTO> 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
}
}