Files
.Data
.vscode
Archive
Server
.vscode
ApiControllers
AppSettingsController.cs
AttachmentsController.cs
AwaitingDispoController.cs
ClientSettingsController.cs
ExportController.cs
InboundController.cs
InfinityQSController.cs
InfinityQSV2Controller.cs
InfinityQSV3Controller.cs
OpenInsightV1Controller.cs
PinController.cs
ReactorsController.cs
ServiceShopOrderController.cs
SpreadingResistanceProfileController.cs
ToolTypesController.cs
Controllers
Data
Models
Properties
Repositories
Services
Views
wwwroot
ApiLoggingMiddleware.cs
OI.Metrology.Server.csproj
Program.cs
compilerconfig.json
compilerconfig.json.defaults
Shared
Tests
View
.editorconfig
.gitignore
OI-Metrology.sln
README.md
azure-pipelines-server-development.yml
azure-pipelines-server.yml
package.json
oi-metrology/Server/ApiControllers/SpreadingResistanceProfileController.cs
Mike Phares e084fdd58f Spreading Resistance Profile with ChartJS,
Copy-On-Get and nuget bump (Serilog)
2023-05-16 08:20:35 -07:00

38 lines
1.8 KiB
C#

using Microsoft.AspNetCore.Mvc;
using OI.Metrology.Shared.Models.Stateless;
using OI.Metrology.Shared.Services;
namespace OI.Metrology.Server.ApiControllers;
[ApiController]
[Route("api/[controller]")]
public partial class SpreadingResistanceProfileController : ControllerBase, ISpreadingResistanceProfileController<IActionResult>
{
private readonly IAttachmentsService _AttachmentsService;
private readonly IMetrologyRepository _MetrologyRepository;
private readonly IToolTypesRepository _ToolTypesRepository;
private readonly ISpreadingResistanceProfileService _SpreadingResistanceProfileService;
public SpreadingResistanceProfileController(IMetrologyRepository metrologyRepository, IAttachmentsService attachmentsService, IToolTypesRepository toolTypesRepository, ISpreadingResistanceProfileService spreadingResistanceProfileService)
{
_MetrologyRepository = metrologyRepository;
_AttachmentsService = attachmentsService;
_ToolTypesRepository = toolTypesRepository;
_SpreadingResistanceProfileService = spreadingResistanceProfileService;
}
[HttpGet]
[Route("{toolTypeId}/{tabletype}/files/{attachmentId}/{filename}")]
public IActionResult GetAttachment(int toolTypeId, string tabletype, string attachmentId, string filename)
{
(string? message, string? contenttype, Stream? stream) = _ToolTypesRepository.GetAttachment(_MetrologyRepository, _AttachmentsService, toolTypeId, tabletype, attachmentId, filename);
if (message is not null)
return Content(message);
else if (contenttype is not null && stream is not null)
return File(_SpreadingResistanceProfileService.GetImageBytes(stream), "image/jpeg");
else
throw new Exception();
}
}