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 MarketData.Utils;
using MarketData.Generator.GainLoss;
using MarketData.MarketDataModel.GainLoss;
using MarketDataServer.Authorization;
using MarketData.Cache;
using MarketData.Generator;

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

		public IEnumerable<String> GetDistinctPriceIndices(String token)
		{
      Console.WriteLine(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)
		{
      Console.WriteLine(String.Format("[{0:G}][PriceIndexController::GetOpenPositionsWithDescriptionAsOf]",DateTime.Now));
      if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
			PriceIndices priceIndices=ConsumerPriceIndexDA.GetConsumerPriceIndex(indexCode);
			return priceIndices;
		} 
	}
}
