using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using System.Windows;
using System.ComponentModel;
using MarketData;
using MarketData.Utils;
using MarketData.Helper;
using MarketData.MarketDataModel;
using MarketData.DataAccess;
using TradeBlotter.Model;
using TradeBlotter.DataAccess;
using TradeBlotter.Command;
using TradeBlotter.ViewModels;

namespace TradeBlotter.Model
{
  public class ValuationModel : ModelBase
  {
    private readonly Valuation valuation;
    private readonly DateTime valuationDate;
    private bool isSelected;

    public ValuationModel(Valuation valuation,DateTime valuationDate)
    {
      if (null == valuation) throw new ArgumentNullException("valuation");
      this.valuation = valuation;
      this.valuationDate = valuationDate;
      PropertyChanged += OnValuationViewModelPropertyChanged;
    }
//***************************************************************************************************
    private void OnValuationViewModelPropertyChanged(object sender, PropertyChangedEventArgs eventArgs)
    {
    }
    public String ValuationDate
    {
      get { return Utility.DateTimeToStringMMSDDSYYYY(valuationDate); }
    }
    public String Symbol
    {
      get{return valuation.Symbol;}
    }
    public String Company
    {
      get{return valuation.Company;}
    }
    public double DebtToEquity
    {
      get{return valuation.DebtToEquity;}
    }
    public String Sector
    {
      get{return valuation.Sector;}
    }
    public String Industry
    {
      get{return valuation.Industry;}
    }
    public double MarketCap
    {
      get{return valuation.MarketCap;}
    }
    public double EarningsYield
    {
      get{return valuation.EarningsYield;}
    }
    public double DividendYield
    {
      get{return valuation.DividendYield;}
    }
    public double EBIT
    {
      get{return valuation.EBIT;}
    }
    public double EnterpriseValue
    {
      get{return valuation.EnterpriseValue;}
    }
    public double OperatingEarnings
    {
      get{return valuation.OperatingEarnings;}
    }
    public double AcquirersMultiple
    {
      get{return valuation.AcquirersMultiple;}
    }
    public double AMRank
    {
      get{return valuation.AMRank;}
    }
    public double TLBRankROIC
    {
      get{return valuation.TLBRankROIC;}
    }
    public double TLBRankROC
    {
      get{return valuation.TLBRankROC;}
    }
    public String SEC13
    {
      get { return Utility.BooleanToYesNoString(valuation.SEC13); }
    }
    public String SEC13FilingDate
    {
      get{return Utility.IsEpoch(valuation.SEC13FilingDate)?Constants.CONST_DASHES:Utility.DateTimeToStringMMHDDHYYYY(valuation.SEC13FilingDate);}
    }
    public String Beta90
    {
      get { return Utility.FormatNumber(valuation.Beta90,2); }
    }
    public String Beta2Y
    {
      get { return Utility.FormatNumber(valuation.Beta720,2); }
    }
    public DateTime NextEarningsDate
    {
      get{return valuation.NextEarningsDate;}
    }
    public String LongTermDebt
    {
      get { return Utility.FormatCurrency(valuation.LongTermDebt); }
    }
    public String Revenue
    {
      get { return Utility.FormatCurrency(valuation.Revenue); }
    }
    public String DebtLoad
    {
      get { return valuation.DebtLoad; }
    }
    public double AverageROIC
    {
      get { return valuation.AverageROIC; }
    }
    public double LatestROIC
    {
      get { return valuation.LatestROIC/100.00; }
    }
    public double LatestROC
    {
      get { return valuation.LatestROC; }
    }
    public double ROICSlope
    {
      get { return valuation.ROICSlope; }
    }
    public String ROICDates
    {
      get { return valuation.ROICDates; }
    }
    public String BVPSDates
    {
      get { return valuation.BVPSDates; }
    }
    public double AverageEquityGrowth
    {
      get { return valuation.AverageEquityGrowth; }
    }
    public double AverageEquityGrowth2Y
    {
      get { return valuation.AverageEquityGrowth2Y; }
    }
    public double AverageEquityGrowth4Y
    {
      get { return valuation.AverageEquityGrowth4Y; }
    }
    public String EPSDates
    {
      get { return valuation.EPSDates; }
    }
    public double AverageEPSGrowth
    {
      get { return valuation.AverageEPSGrowth; }
    }
    public double AverageEPSGrowth2Y
    {
      get { return valuation.AverageEPSGrowth2Y; }
    }
    public double AverageEPSGrowth4Y
    {
      get { return valuation.AverageEPSGrowth4Y; }
    }
    public String RevenueDates
    {
      get { return valuation.RevenueDates; }
    }
    public double AverageRevenueGrowth
    {
      get { return valuation.AverageRevenueGrowth; }
    }
    public double AverageRevenueGrowth2Y
    {
      get { return valuation.AverageRevenueGrowth2Y; }
    }
    public double AverageRevenueGrowth4Y
    {
      get { return valuation.AverageRevenueGrowth4Y; }
    }
    public double AverageFreeCashflowGrowth
    {
      get { return valuation.AverageFreeCashflowGrowth; }
    }
    public double AverageOperatingCashflow
    {
      get { return valuation.AverageOperatingCashflow; }
    }
    public double AverageWorkingCapital
    {
      get { return valuation.AverageWorkingCapital; }
    }
    public double BVPS
    {
      get { return valuation.BVPS; }
    }
    public double PBVPS
    {
      get { return valuation.PBVPS; }
    }
    public double EPS
    {
      get { return valuation.EPS; }
    }
    public double PE
    {
      get { return valuation.PE; }
    }
    public double PEG
    {
      get { return valuation.PEG; }
    }
    public double ImpliedEarningsGrowth
    {
      get { return valuation.ImpliedEarningsGrowth; }
    }
    public double LowPE
    {
      get { return valuation.LowPE; }
    }
    public double TrailingPE
    {
      get { return valuation.TrailingPE; }
    }
    public double AverageLowTrailing
    {
      get { return valuation.AverageLowTrailing; }
    }
    public double CurrentStockEstimatePrice
    {
      get { return valuation.CurrentStockEstimatePrice; }
    }
    public double PriceEstimate10Y
    {
      get { return valuation.PriceEstimate10Y; }
    }
    public double TodaysPriceForRequiredReturn
    {
      get { return valuation.TodaysPriceForRequiredReturn; }
    }
    public double MOS
    {
      get { return valuation.MOS; }
    }
    public double MOS80
    {
      get { return valuation.MOS80; }
    }
    public double IntrinsicValue
    {
      get { return valuation.IntrinsicValue; }
    }
    public double FundamentalValue
    {
      get{return valuation.FundamentalValue;}
    }
    public double NetCurrentAssetValuePerShare
    {
      get{return valuation.NetCurrentAssetValuePerShare;}
    }
    public double RGV
    {
      get { return valuation.RGV; }
    }
    public double LatestPrice
    {
      get { return valuation.LatestPrice; }
    }
    public double UpsidePcnt
    {
      get { return valuation.UpsidePcnt; }
    }
    public double DownsidePcnt
    {
      get { return valuation.DownsidePcnt; }
    }
    public double MeanTargetPrice
    {
      get { return valuation.MeanTargetPrice; }
    }
    public double LowTargetPrice
    {
      get { return valuation.LowTargetPrice; }
    }
    public double HighTargetPrice
    {
      get { return valuation.HighTargetPrice; }
    }
    public String Bargain
    {
      get { return Utility.BooleanToYesNoString(valuation.Bargain); }
    }
    public String Bargain80
    {
      get { return Utility.BooleanToYesNoString(valuation.Bargain80); }
    }
    public String SharesOutstanding
    {
      get { return Utility.FormatNumber(valuation.SharesOutstanding,0,true); }
    }
    public String OperatingCashflow
    {
      get { return Utility.FormatCurrency(valuation.OperatingCashflow,2); }
    }
    public String PCF(double price=double.NaN)
    {
      return Utility.FormatNumber(valuation.PCF(price),2,true);
    }
    public String DateGenerated
    {
      get { return Utility.DateTimeToStringMMSDDSYYYY(valuation.Modified); }
    }
    public bool IsSelected
    {
      get { return isSelected; }
      set
      {
        if (value == isSelected) return;
        isSelected = value;
        base.OnPropertyChanged("IsSelected");
      }
    }
  }

}
