Files
mapo-core/MP.SPEC/Controllers/RecipeArchiveController.cs
T
Samuele Locatelli 7c9406682c SPEC:
- pulizia vecchio controller/repository globale
- pulizia MpDataService
- aggiunta file readme progetto
- update refactor progetto e config
2026-06-04 13:45:46 +02:00

77 lines
2.2 KiB
C#

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using MP.SPEC.Data;
using NLog;
namespace MP.SPEC.Controllers
{
[Route("api/[controller]")]
[ApiController]
[AllowAnonymous]
public class RecipeArchiveController : ControllerBase
{
#region Public Constructors
public RecipeArchiveController(IConfiguration configuration, MpDataService DataService)
{
Log.Info("Starting RecipeArchiveController");
DService = DataService;
Log.Info("Avviata classe RecipeArchiveController");
}
#endregion Public Constructors
#region Public Methods
[HttpGet("GetByPODL")]
public async Task<string> GetByPODL(string idxMacc, int idxPODL)
{
string answ = "";
string archPath = await DService.MacchineRecipeArchiveAsync(idxMacc);
var podlData = await DService.POdlGetByKey(idxPODL);
if (podlData != null)
{
string fileName = podlData?.Recipe ?? "";
string fullPath = Path.Combine(archPath, fileName);
if (!string.IsNullOrEmpty(fullPath))
{
answ = System.IO.File.ReadAllText(fullPath);
}
}
return answ;
}
[HttpGet("GetFile")]
public async Task<string> GetFile(string idxMacc, string fileName)
{
string answ = "";
string archPath = await DService.MacchineRecipeArchiveAsync(idxMacc);
if (!string.IsNullOrEmpty(archPath))
{
string fullPath = Path.Combine(archPath, fileName);
if (!string.IsNullOrEmpty(fullPath))
{
answ = System.IO.File.ReadAllText(fullPath);
}
}
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 Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
}
}