mirror of
https://gitlab.com/Hukuta47/cartrix.git
synced 2026-12-05 04:20:55 +00:00
38 lines
1022 B
C#
38 lines
1022 B
C#
using CartriX.Shared.Classes;
|
|
using CartriX.Shared.Mappers;
|
|
using CartriX.Shared.Models;
|
|
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.ToList().Select(l => l.OnlyName());
|
|
return Ok(locations);
|
|
}
|
|
[HttpGet("{Id}")]
|
|
public IActionResult GetLocationListPrinters(int id)
|
|
{
|
|
var printers = _context.Printers.Where(p => p.locationId == id).Select(p => p.OnlyName());
|
|
|
|
if (!printers.Any())
|
|
{
|
|
return NotFound();
|
|
}
|
|
|
|
return Ok(printers);
|
|
}
|
|
}
|
|
} |