using AutoMapper;
using Microsoft.AspNetCore.Authorization;
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.Core.Repositories.Interfaces;
using PARR.Domain.Common.Roles;
namespace PARR.API.Controllers.V1
{
[Authorize(Roles = ParrRoles.EsppRobot.RoleOrAdmin)]
public class RobotHistoryLevelController : BaseApiController
{
private readonly IMapper mapper;
private readonly IRobotHistoryLevelRepository robotHistoryLevelService;
public RobotHistoryLevelController(
IMapper mapper,
IRobotHistoryLevelRepository 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));
}
}
}