mirror of
https://gitlab.com/Hukuta47/cartrix.git
synced 2026-12-06 13:00:55 +00:00
Сделал список OID адресов, добавил миграцию бд при запуске программы
This commit is contained in:
1 parent
48e625819a
commit
bd426d2647
35 files changed
+927
-46
No files matched your search
@@ -3,5 +3,6 @@
|
||||
public interface ILocationService
|
||||
{
|
||||
public Task<List<Entities.Location>> List();
|
||||
public Task<List<Entities.Printer>> PrintersList(int LocationId);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using CartriX.Api.Controllers.Printer;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace CartriX.Api.Controllers.Location
|
||||
@@ -8,7 +8,7 @@ namespace CartriX.Api.Controllers.Location
|
||||
public class LocationController(ILocationService _locationService) : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Получить список местоположений
|
||||
/// Получить список локаций
|
||||
/// </summary>
|
||||
[ProducesResponseType(typeof(List<Shared.Models.Location.LocationItem>), StatusCodes.Status200OK)]
|
||||
[HttpGet(nameof(List))]
|
||||
@@ -16,5 +16,14 @@ namespace CartriX.Api.Controllers.Location
|
||||
{
|
||||
return Ok((await _locationService.List()).Select(l => l.ToItem()));
|
||||
}
|
||||
/// <summary>
|
||||
/// Получить список прирнтеров на локации
|
||||
/// </summary>
|
||||
[ProducesResponseType(typeof(List<Shared.Models.Location.LocationItem>), StatusCodes.Status200OK)]
|
||||
[HttpGet(nameof(ListPrinters))]
|
||||
public async Task<ActionResult> ListPrinters([FromQuery] int LocationId)
|
||||
{
|
||||
return Ok((await _locationService.PrintersList(LocationId)).Select(p => p.ToItemList()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,9 @@ namespace CartriX.Api.Controllers.Location
|
||||
{
|
||||
public static Shared.Models.Location.LocationItem ToItem(this Entities.Location location) => new()
|
||||
{
|
||||
Id = location.Id,
|
||||
Name = location.Name,
|
||||
Printers = location.Printers.Select(p => p.ToItemList()).ToList()
|
||||
};
|
||||
CountPrinters = (byte)location.Printers.Count
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
using CartriX.Shared.Models.Location;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace CartriX.Api.Controllers.Location
|
||||
{
|
||||
public class LocationService(AppDbContext _context) : ILocationService
|
||||
{
|
||||
public async Task<List<Entities.Location>> List() => await _context.Locations.Include(l => l.Printers).ThenInclude(p => p.Model).ThenInclude(m => m.Manufacturer).ToListAsync();
|
||||
}
|
||||
public async Task<List<Entities.Location>> List() => await _context.Locations.Include(l => l.Printers).ToListAsync();
|
||||
|
||||
public async Task<List<Entities.Printer>> PrintersList(int LocationId) => await _context.Printers.Include(p => p.Status).Include(p => p.Model).Where(p => p.Location.Id == LocationId).ToListAsync();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user