Files
parr_api/PARR.API/Controllers/V1/EsppDataController.cs
Mikhail Trubnikov 06de8926e4 template controller
2023-09-15 16:32:46 +10:00

56 lines
2.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using PARR.API.Contracts.V1;
using PARR.API.Contracts.V1.Responses.Base;
using PARR.API.Controllers.V1.Base;
using PARR.BLL.Services.Interfaces;
using PARR.BLL.Settings;
namespace PARR.API.Controllers.V1
{
public class EsppDataController : BaseApiController
{
private readonly ILogger<EsppDataController> logger;
private readonly IFileService fileService;
private readonly StorageSettings storageSettings;
public EsppDataController(
ILogger<EsppDataController> logger,
IFileService fileService,
StorageSettings storageSettings
)
{
this.logger = logger;
this.fileService = fileService;
this.storageSettings = storageSettings;
}
// UploadTemplates - неактуально, так как стали брать данные с RabbitMQ
///// <summary>
///// Загрузить файл списка шаблонов полученных из ЕСПП в формате csv
///// </summary>
///// <returns></returns>
//[HttpPost(ApiRoutes.EsppData.UploadTemplates)]
//public async Task<IActionResult> UploadTemplates([BindRequired] IFormFile file)
//{
// if (!fileService.IsExtensionAllowed(file, storageSettings.EsppTemplates!.AllowedExtensions))
// return BadRequest(
// new Response(false,
// new List<ErrorModel> {
// new ErrorModel {
// Message = $"Недопустимое расширение файла. Разрешенные расширения: {string.Join(", ", storageSettings.EsppTemplates.AllowedExtensions)}"
// } }));
// if (!fileService.IsNotExceededLimit(file, storageSettings.EsppTemplates.MaxFileSizeMb))
// return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { FieldName = nameof(file), Message = $"Размер файла превышает {storageSettings.EsppTemplates.MaxFileSizeMb} МБайт" } }));
// var uploadResult = await fileService.UploadAsync(file, storageSettings.EsppTemplates.TemplatePath);
// if (uploadResult == null)
// return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка при сохранении файла" } }));
// return Ok(new Response<string>("", true, new List<ErrorModel>(), $"Файл загружен."));
//}
}
}