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;
}
///
/// Получить список уровней истории работы робота
///
///
[HttpGet(ApiRoutes.RobotHistoryLevel.GetAll)]
public async Task GetAll()
{
var levels = await robotHistoryLevelService.Get()
.OrderBy(t => t.Level)
.ToListAsync();
var response = mapper.Map>(levels);
return Ok(new Response>(response, true));
}
}
}