private void CheckName(Item xbrlItem, ref Company comp)
 {
     if (xbrlItem.Name.Contains("EntityRegistrantName"))
     {
         comp.CompanyName = xbrlItem.Value;
     }
 }
 private void CheckFilerCategory(Item xbrlItem, ref Company comp)
 {
     if (xbrlItem.Name.Contains("EntityFilerCategory"))
     {
         comp.Industry = xbrlItem.Value;
     }
 }
 public void UpdateCompany(Company company)
 {
     if (CompanyExists(company.Symbol))
     {
         _dao.UpdateCompany(company);
     }
     else
     {
         _dao.InsertCompany(company);
     }
 }
        public Company Populate(XbrlDocument xbrlDoc, string symbol)
        {
            Company comp = new Company();
            comp.Symbol = symbol;
            foreach (XbrlFragment frag in xbrlDoc.XbrlFragments)
            {
                foreach (Item xbrlItem in frag.Facts)
                {
                    comp = CheckItem(xbrlItem, comp);
                }
            }

            return comp;
        }
        private void CreateCompanyObject(string symbol, JeffFerguson.Gepsio.XbrlDocument xbrlDoc, Dictionary<string, Object> yahooStats)
        {
            XbrlCompanyFilter compFilter = new XbrlCompanyFilter();
            Company compToAdd = new Company();
            compToAdd = compFilter.Populate(xbrlDoc, symbol);

            compToAdd.Industry = Convert.ToString(yahooStats["Industry"]);
            compToAdd.Sector = Convert.ToString(yahooStats["Sector"]);
            CompanyBL.Instance.UpdateCompany(compToAdd);
        }
 private static void SetCompanyParameters(Company company, MySqlParameter[] parms)
 {
     parms[0].Value = company.Symbol;
     parms[1].Value = company.CompanyName;
     parms[2].Value = company.Industry;
     parms[3].Value = company.Sector;
 }
        private Company ConvertReaderToCompanyObject(MySqlDataReader rdr)
        {
            Company cmp = new Company();
            cmp.Symbol = MySqlHelper.ConvertReaderToString(rdr, "SYMBOL");
            cmp.CompanyName = MySqlHelper.ConvertReaderToString(rdr, "COMPANY_NAME");
            cmp.Industry = MySqlHelper.ConvertReaderToString(rdr, "INDUSTRY");
            cmp.Sector = MySqlHelper.ConvertReaderToString(rdr, "SECTOR");

            return cmp;
        }
        public void UpdateCompany(Company company)
        {
            MySqlParameter[] parms = GetCompanyParameters();
            SetCompanyParameters(company, parms);

            using (MySqlConnection conn = new MySqlConnection(MySqlHelper.SV_CONN_STRING))
            {
                conn.Open();
                MySqlHelper.ExecuteNonQuery(conn, SQL_UPDATE_COMPANY, parms);
            }
        }
        private Company CheckItem(Item xbrlItem, Company comp)
        {
            CheckName(xbrlItem, ref comp);

            return comp;
        }
        private CompanyValuationStatistics GetCompanyValuationStatistics(Company comp)
        {
            IncomeStatementProjectionBL incProjectionBL = new IncomeStatementProjectionBL();

            CompanyValuationStatistics cvs = new CompanyValuationStatistics();
            cvs.Symbol = comp.Symbol;
            cvs.Year = IncomeStatementBL.Instance.GetLastYear(comp.Symbol);
            cvs.NoOfYears = 5;
            cvs.CompanyName = comp.CompanyName;
            cvs.NoGrowthProjections = incProjectionBL.ProjectIncomeStatementsNoRevenueGrowth(comp.Symbol, cvs.Year, cvs.NoOfYears);
            cvs.AvgGrowthProjections = incProjectionBL.ProjectIncomeStatementsAvgRevenueGrowth(comp.Symbol, cvs.Year, cvs.NoOfYears);
            cvs.DecayGrowthProjections = incProjectionBL.ProjectIncomeStatementsDecayRevenueGrowth(comp.Symbol, cvs.Year, cvs.NoOfYears, (decimal)-0.05);
            DCFMngr().GetDiscountedCashFlows(cvs);

            return cvs;
        }
        private void EnterIntoCompanyTableFromYahooApi(string symbol)
        {
            YahooApiGateway api = new YahooApiGateway();
            Dictionary<string, Object> stats = new Dictionary<string, object>();

            api.RetrieveYahooCompanyInfo(symbol, ref stats);

            Company comp = new Company(symbol, Convert.ToString(stats["Name"]), Convert.ToString(stats["Industry"]), Convert.ToString(stats["Sector"]));

            CompanyBL.Instance.UpdateCompany(comp);
        }