d8ad3d4a03
- correzione pubxml - fix minori compilazione
75 lines
2.1 KiB
C#
75 lines
2.1 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using MP.SPEC.Data;
|
|
using Newtonsoft.Json;
|
|
using NLog;
|
|
using System.Xml;
|
|
|
|
namespace MP.SPEC.Controllers
|
|
{
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
[AllowAnonymous]
|
|
public class RecipeController : ControllerBase
|
|
{
|
|
#region Public Constructors
|
|
|
|
public RecipeController(IConfiguration configuration, MpDataService DataService)
|
|
{
|
|
Log.Info("Starting RecipeController");
|
|
_configuration = configuration;
|
|
DService = DataService;
|
|
Log.Info("Avviata classe 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)
|
|
{
|
|
string answ = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
|
|
// recupero versione json
|
|
string rawData = await GetRecipe(idxPODL);
|
|
if (!string.IsNullOrEmpty(rawData))
|
|
{
|
|
// aggiungo root node?
|
|
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
|
|
}
|
|
} |