using System;
using System.Web.Http;
using WindowsDataCenter.Helpers;
using Interfaces;

namespace WindowsDataCenter
{
    [RoutePrefix("api/cards")]
    public class CardsController : ApiController
    {
        private readonly IRepository _repo;
        private readonly ILogger _logger;
        public CardsController(IRepository repo, ILogger logger)
        {
            if(repo == null) throw new ArgumentNullException(nameof(repo));
            _repo = repo;
            if(logger == null) throw new ArgumentNullException(nameof(logger));
            _logger = logger;
        }

        [HttpGet]
        [Route("unassigned")]
        [CacheControl(MaxAge = 0)]
        public IHttpActionResult GetUnassignedCards()
        {
            var unassignedCards = _repo.GetUnassignedIdentifierList();
            _logger.Trace("Call to GetUnassignedCards, returning {0} items", unassignedCards.data.Count);
            return Ok(unassignedCards);
        }
    }
}