using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Txgy.RBS.DbModel.Models;
using Txgy.RBS.DTO;
using Txgy.RBS.Framework.Api;
using Txgy.RBS.IServices;
using Txgy.RBS.Services;

namespace Txgy.RBS.Server.WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ResultInfoController : ControllerBase
    {
        private readonly IResultInfoService _resultInfoService;

        public ResultInfoController(ILogger<ResultInfoController> logger, IResultInfoService resultInfoService)
        {
            this._resultInfoService = resultInfoService;
        }
        [HttpPost]
        public ApiResult AddResultInfo(ResultDTO resultDTO)
        {
            return _resultInfoService.AddResultInfo(resultDTO);
        }

        [HttpDelete("{id}")]
        public ApiResult DeleteResultInfo(int id)
        {
            return _resultInfoService.DeleteResultInfo(id);
        }

        [HttpPost]
        public ApiResult UpdateResultInfo(ResultDTO resultDTO)
        {
            return _resultInfoService.UpdateResultInfo(resultDTO);
        }

        [HttpGet("{id}")]
        public ResultDTO GetResultInfo(int id)
        {
            return _resultInfoService.GetResultInfo(id);
        }
        [HttpGet]
        public List <ResultDTO> GetResultInfo(string projectName, DateTime startTime, DateTime endTime)
        {
            return _resultInfoService.GetResultInfo(projectName.Trim(), startTime, endTime);
        }

        [HttpGet]
        public List<ResultDTO> GetAllResultInfo()
        {
            return _resultInfoService.GetAllResultInfo();
        }

        [HttpPost]
        public ApiResult AddRedisInfo(RedisInfoDTO redisDTO)
        {
            return _resultInfoService.AddRedisInfo(redisDTO);
        }

        [HttpDelete("{id}")]
        public ApiResult DeleteRedisInfo(int id)
        {
            return _resultInfoService.DeleteRedisInfo(id);
        }

        [HttpPost]
        public ApiResult UpdateRedisInfo(RedisInfoDTO redisDTO)
        {
            return _resultInfoService.UpdateRedisInfo(redisDTO);
        }

        [HttpGet]
        public List<RedisInfoDTO> GetAllRedisInfo()
        {
            return _resultInfoService.GetAllRidesInfo();
        }
    }
}
