using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Aurora.Core.IService;
using Aurora.Core.IService.Dto;
using Aurora.Infrastructure.Response;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace Aurora.Core.Api.Controllers
{
    [ApiController]
    [Route("[controller]/[action]")]
    public class CategoryController : ControllerBase
    {
        private readonly ILogger<CategoryController> _logger;
        private readonly ICategoryService _categoryService;

        public CategoryController(ILogger<CategoryController> logger,
        ICategoryService categoryService)
        {
            _logger = logger;
            _categoryService = categoryService;
        }

        [HttpGet]
        /// <summary>
        /// get cateories list
        /// </summary>
        /// <returns></returns>
        public async Task<IActionResult> GetList()
        {
            var res = await _categoryService.GetList();
            return Ok(res);
        }

        [HttpGet]
        /// <summary>
        /// get cateory by id
        /// </summary>
        /// <returns></returns>
        public async Task<ResponseModel<CategoryDto>> GetById(int id)
        {
            var res = await _categoryService.GetById(id);
            return res;
        }

        [HttpPost]
        /// <summary>
        /// add cateory
        /// </summary>
        /// <returns></returns>
        public async Task<ResponseModel<CategoryDto>> Add(CategoryDto model)
        {
            var res = await _categoryService.Add(model);
            return res;
        }
    }
}
