130 lines
3.6 KiB
C#
130 lines
3.6 KiB
C#
using GPW.CORE.Api.Data;
|
|
using GPW.CORE.Data;
|
|
using GPW.CORE.Data.DbModels;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using NLog;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace GPW.CORE.Api.Controllers
|
|
{
|
|
/// <summary>
|
|
/// Controller interazione VC19
|
|
/// </summary>
|
|
[Route("api/VC19")]
|
|
[ApiController]
|
|
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
|
|
|
|
/// <summary>
|
|
/// Init generico
|
|
/// </summary>
|
|
/// <param name="DataService"></param>
|
|
public VC19Controller(ApiDataService DataService)
|
|
{
|
|
_DataService = DataService;
|
|
Log.Info("Avviata classe VC19Controller");
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Protected Properties
|
|
|
|
/// <summary>
|
|
/// Dataservice x accesso DB
|
|
/// </summary>
|
|
protected ApiDataService _DataService { get; set; }
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Public Methods
|
|
|
|
/// <summary>
|
|
/// Recupera ultimi 20 check in ordine cronologico inverso
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public async Task<List<CheckVc19Model>> Get()
|
|
{
|
|
var result = await _DataService.ChecksGetLast(20);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Recupera ultimo mese di check x dipendente indicato da ID
|
|
/// GET api/VC19/5
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("{id}")]
|
|
public async Task<List<CheckVc19Model>> Get(int id)
|
|
{
|
|
var result = await _DataService.ChecksGetByDip(id);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Invio record decodificato da classe DCC
|
|
/// </summary>
|
|
/// <param name="DecodedData"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<VC19Check> Post(DCCDecode DecodedData)
|
|
{
|
|
VC19Check answ = new VC19Check()
|
|
{
|
|
Result = "KO"
|
|
};
|
|
var result = await _DataService.InsertCheck(DecodedData, "10.74.82.255");
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Invio DI TEST record manuale
|
|
/// </summary>
|
|
/// <param name="DecodedData"></param>
|
|
/// <returns></returns>
|
|
[HttpPut]
|
|
public async Task<VC19Check> Put(int id)
|
|
{
|
|
VC19Check answ = new VC19Check()
|
|
{
|
|
Result = "KO"
|
|
};
|
|
var result = await _DataService.InsertManual(id, "10.74.82.255");
|
|
answ = new VC19Check
|
|
{
|
|
DTRecord = DateTime.Now,
|
|
CheckRecorded = true,
|
|
TimbrRecorder = true,
|
|
Result = $"OK, Check Recorded for id {id}"
|
|
};
|
|
return answ;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |