Files
gpw_next/GPW.Api/GPW.Api/Controllers/VC19Controller.cs
T
2021-10-18 17:52:31 +02:00

84 lines
2.1 KiB
C#

using GPW.Api.Data;
using GPW.Data;
using GPW.Data.DBModels;
using Microsoft.AspNetCore.Mvc;
using NLog;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace GPW.Api.Controllers
{
[Route("api/VC19")]
[ApiController]
//[Route("[controller]")]
public class VC19Controller : ControllerBase
{
#region Private Fields
/// <summary>
/// Classe per logging
/// </summary>
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
#region Public Constructors
public VC19Controller(GpwDataService DataService)
{
_DataService = DataService;
Log.Info("Avviata classe PlantDataController");
}
#endregion Public Constructors
#region Protected Properties
protected GpwDataService _DataService { get; set; }
#endregion Protected Properties
#region Public Methods
[HttpGet]
public async Task<List<CheckVc19>> Get()
{
var result = await _DataService.ChecksGetLast(20);
return result;
}
// GET api/VC19/5
[HttpGet("{id}")]
public async Task<List<CheckVc19>> Get(int id)
{
var result = await _DataService.ChecksGetByDip(id);
return result;
}
[HttpPost]
public async Task<VC19Check> Post(DCCDecode DecodedData)
{
VC19Check answ = new VC19Check()
{
Result = "KO"
};
var result = await _DataService.InsertCheck(DecodedData, "0.0.0.0");
if (result)
{
answ = new VC19Check
{
DTRecord = DateTime.Now,
CheckRecorded = true,
TimbrRecorder = true,
Result = $"OK, Check Recorded for {DecodedData.nam.fn} {DecodedData.nam.gn} {DecodedData.dob:yyyy.MM.dd}"
};
}
else
{ }
return answ;
}
#endregion Public Methods
}
}