using MarketData.MarketDataModel;
using MarketData.DataAccess;
using MarketDataServer.Authorization;
using MarketData;
using Microsoft.AspNetCore.Mvc;
using LogLevel = MarketData.LogLevel;

namespace MarketDataServer.Controllers
{
  [ApiController]
  [Route("api/[controller]/[action]")]
  public class PriceIndexController : ControllerBase
	{
//http://localhost:8000/api/PriceIndex/GetDistnctPriceIndices
		[HttpGet(Name = "GetDistinctPriceIndices")]
		public IEnumerable<String> GetDistinctPriceIndices(String token)
		{
      MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PriceIndexController::GetDistinctPriceIndices]",DateTime.Now));
      if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
			return ConsumerPriceIndexDA.GetDistinctIndices();
		} 

		[HttpGet(Name = "GetConsumerPriceIndex")]
		public IEnumerable<PriceIndex> GetConsumerPriceIndex(String token,String indexCode)
		{
      MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PriceIndexController::GetOpenPositionsWithDescriptionAsOf]",DateTime.Now));
      if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
			PriceIndices priceIndices=ConsumerPriceIndexDA.GetConsumerPriceIndex(indexCode);
			return priceIndices;
		} 
	}
}
