using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using MarketData.MarketDataModel;
using MarketData.DataAccess;
using MarketDataServer.Authorization;
using MarketData;

namespace MarketDataServer.Controllers
{
  public class PriceIndexController : ApiController
	{
//http://localhost:8000/api/PriceIndex/GetDistnctPriceIndices

		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();
		} 

		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;
		} 
	}
}
