feat(api): Контроллер управления историей робота. Контролпер по получению списка уровней истории робота
This commit is contained in:
42
PARR.API/Controllers/V1/RobotHistoryLevelController.cs
Normal file
42
PARR.API/Controllers/V1/RobotHistoryLevelController.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
public class RobotHistoryLevelController : BaseApiController
|
||||
{
|
||||
private readonly IMapper mapper;
|
||||
private readonly IRobotHistoryLevelService robotHistoryLevelService;
|
||||
|
||||
public RobotHistoryLevelController(
|
||||
IMapper mapper,
|
||||
IRobotHistoryLevelService robotHistoryLevelService
|
||||
)
|
||||
{
|
||||
this.mapper = mapper;
|
||||
this.robotHistoryLevelService = robotHistoryLevelService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получить список уровней истории работы робота
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.RobotHistoryLevel.GetAll)]
|
||||
public async Task<IActionResult> GetAll()
|
||||
{
|
||||
var levels = await robotHistoryLevelService.Get()
|
||||
.OrderBy(t => t.Level)
|
||||
.ToListAsync();
|
||||
|
||||
var response = mapper.Map<List<RobotHistoryLevelResponse>>(levels);
|
||||
|
||||
return Ok(new Response<List<RobotHistoryLevelResponse>>(response, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user