Files
gwms/GWMS.UI/Controllers/PlantDataController.cs
T
2021-06-30 10:16:15 +02:00

75 lines
1.9 KiB
C#

using GWMS.Data.DTO;
using GWMS.UI.Data;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
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 Public Constructors
public PlantDataController(GWMSDataService DataService)
{
_DataService = DataService;
}
#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)
{
}
// GET: api/PlantData
[HttpGet]
public async Task<List<PlantDTO>> Get()
{
// serializzo i dati di PlantDTO dell'impianto richiesto
List<PlantDTO> ListRecords = await _DataService.PlantsGetAll();
return ListRecords;
}
// GET api/PlantData/5
[HttpGet("{id}")]
public async Task<PlantDTO> Get(int id)
{
// serializzo i dati di PlantDTO dell'impianto richiesto
var ListRecords = await _DataService.PlantsGetAll();
//seleziono plant...
var SelRecords = ListRecords.Where(X => X.PlantId == id).FirstOrDefault();
return SelRecords;
}
// POST api/PlantData
[HttpPost]
public void Post([FromBody] string value)
{
}
// PUT api/PlantData/5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
}
#endregion Public Methods
}
}