Files
Samuele Locatelli 6355f1eaca IOB Deploy CI/CD:
- fix yaml
- fix conf appsettings.json + production
- global refresh
2023-04-04 19:36:47 +02:00

73 lines
2.0 KiB
C#

using Microsoft.AspNetCore.Mvc;
using MP.IOC.Data;
using Newtonsoft.Json;
using NLog;
using System.Xml;
namespace MP.IOC.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class RecipeController : ControllerBase
{
#region Public Constructors
public RecipeController(IConfiguration configuration, MpDataService DataService)
{
Log.Info("Starting RecipeController");
_configuration = configuration;
DService = DataService;
Log.Info("Avviata RecipeController");
}
#endregion Public Constructors
#region Public Methods
[HttpGet("GetRecipe")]
public async Task<string> GetRecipe(int idxPODL)
{
string answ = "";
var reqRecipe = await DService.RecipeGetByPODL(idxPODL);
if (reqRecipe != null)
{
answ = DService.CalcRecipe(reqRecipe);
}
return answ;
}
[HttpGet("GetRecipeXML")]
public async Task<string> GetRecipeXML(int idxPODL)
{
// aggiungo root node?
string answ = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
// recupero versione json
string rawData = await GetRecipe(idxPODL);
if (!string.IsNullOrEmpty(rawData))
{
XmlDocument doc = (XmlDocument)(JsonConvert.DeserializeXmlNode(rawData) ?? new XmlDocument());
answ += doc.InnerXml;
}
return answ;
}
#endregion Public Methods
#region Protected Properties
/// <summary>
/// Dataservice x accesso DB
/// </summary>
protected MpDataService DService { get; set; }
#endregion Protected Properties
#region Private Fields
private static IConfiguration _configuration = null!;
private static Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
}
}