using System.Text.Json; using System.Text.Json.Serialization; using CutList.Web.DTOs; using CutList.Web.Services; using Microsoft.AspNetCore.Mvc; namespace CutList.Web.Controllers; [ApiController] [Route("api/[controller]")] public class CatalogController : ControllerBase { private readonly CatalogService _catalogService; public CatalogController(CatalogService catalogService) { _catalogService = catalogService; } [HttpGet("export")] public async Task Export() { var data = await _catalogService.ExportAsync(); var options = new JsonSerializerOptions { WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, PropertyNamingPolicy = JsonNamingPolicy.CamelCase }; return new JsonResult(data, options); } [HttpPost("import")] public async Task> Import([FromBody] CatalogData data) { var result = await _catalogService.ImportAsync(data); return Ok(result); } }