mirror of
https://gitlab.com/Hukuta47/cartrix.git
synced 2026-12-05 12:30:55 +00:00
36 lines
932 B
C#
36 lines
932 B
C#
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);
|
|
}
|
|
}
|
|
} |