using CartriX.Shared.DTOs.Location; using CartriX.Shared.DTOs.Printer; using CartriX.Shared.Mappers; using CartriX.Shared.Models; using CartriX.Shared.Patterns; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; namespace CartriX.Api.Controllers { [ApiController] [Route("api/[controller]")] public class LocationController : ControllerBase { private readonly AppDbContext _context; public LocationController(AppDbContext context) { _context = context; } [HttpGet("List")] public IActionResult GetListLocations() { var locations = _context.Locations.Include(l => l.Printers).ToList(); var result = locations.Select(l => new PrintersAndLocations { Name = l.Name, Printers = l.Printers }).ToList(); return Ok(result); } } }