internal string GetCompanyID() { string result = ""; Guid new_guid = Guid.NewGuid(); using (ProjectContext project = new ProjectContext()) { var query_project = (from c in project.project_info where c.Reference_ID == ProjectID select new { TargetCompany = c.Target_Company }).FirstOrDefault(); var query_company = (from a in project.company_basics where a.Company_Name == CompanyName select new { CompanyID = a.Company_ID }).FirstOrDefault(); if (query_project != null) result = query_project.TargetCompany; else if (query_company != null) result = query_company.CompanyID; else result = new_guid.ToString(); } return result; }
internal string GetCompanyID() { string result = ""; Guid new_guid = Guid.NewGuid(); using (ProjectContext check_context = new ProjectContext()) { var query = from company in check_context.company_basics where company.Stock_Code == StockCode select new { CompanyID = company.Company_ID }; if (query.Any()) { foreach (var company in query) { result = company.CompanyID; } } else result = new_guid.ToString(); } return result; }
internal void ExportData() { CompanyID = GetCompanyID(); using (ProjectContext project = new ProjectContext()) using (var transaction = new TransactionScope()) { company_basics new_company_basics = new company_basics { Company_ID = this.CompanyID, Company_Name = this.CompanyName, Domicile = this.Domicile, Industry = this.Industry, Exchange = string.Empty, Stock_Code = string.Empty }; project.company_basics.AddOrUpdate(c => c.Company_ID, new_company_basics); project.SaveChanges(); project_info new_project_info = new project_info() { Reference_ID = this.ProjectID, Target_Company = this.CompanyID, Valuation_Date = this.ValuationDate, Valuation_Type = this.ValuationType, Periodity = this.ReferencePeriodity, Client_Company = string.Empty, Account_Owner = string.Empty, Responsible_Person_1 = string.Empty, Responsible_Person_2 = string.Empty, Description = string.Empty }; project.project_info.AddOrUpdate(c => c.Reference_ID, new_project_info); project.SaveChanges(); country_tax_rate new_country_tax_rate = new country_tax_rate { Date = this.ValuationDate, Country = this.Domicile, Corporate_Tax_Rate = this.MarginalTaxRate }; project.country_tax_rate.AddOrUpdate(c => new { c.Country, c.Date }, new_country_tax_rate); project.SaveChanges(); country_equity_risk_premium new_country_equity_risk_premium = new country_equity_risk_premium { Country = this.Domicile, Date = this.ValuationDate, Expected_Market_Return = this.ExpectedMarketReturn, Risk_Free_Rate = this.RiskFreeRate, Equity_Risk_Premium = this.EquityRiskPremium }; project.country_equity_risk_premium.AddOrUpdate(c => new { c.Country, c.Date }, new_country_equity_risk_premium); project.SaveChanges(); wacc_target_specific_data new_wacc_target_specific_data = new wacc_target_specific_data { Project = this.ProjectID, Version = this.ProjectVersion, Valuation_Date = this.ValuationDate, Beta_Period = this.BetaPeriod, Small_Company_Size_Premium = this.SmallCompanySizePremium, Company_Specific_Risk_Premium = this.CompanySpecificRiskPremium, Cost_of_Debt = this.CostOfDebt }; project.wacc_target_specific_data.AddOrUpdate(c => new { c.Project, c.Version }, new_wacc_target_specific_data); project.SaveChanges(); transaction.Complete(); } }
internal void ExportData() { CompanyID = GetCompanyID(); using (ProjectContext project = new ProjectContext()) using (var transaction = new TransactionScope()) { company_basics new_company_basics = new company_basics { Company_ID = this.CompanyID, Stock_Code = this.StockCode }; project.company_basics.AddOrUpdate(c => c.Company_ID, new_company_basics); project.SaveChanges(); balance_sheet new_balance_sheet = new balance_sheet { Company_ID = this.CompanyID, Date = this.ReferenceDate, Currency = this.Currency, Total_Debt = this.TotalDebt * GetScale(UnitOfCurrency) }; project.balance_sheet.AddOrUpdate(c => new {c.Company_ID, c.Date }, new_balance_sheet); project.SaveChanges(); equity_market_data new_equity_market_data = new equity_market_data { Company_ID = this.CompanyID, Date = this.ReferenceDate, Currency = this.Currency, Market_Cap = this.MarketCap * GetScale(UnitOfCurrency) }; project.equity_market_data.AddOrUpdate(c => new {c.Company_ID, c.Date }, new_equity_market_data); project.SaveChanges(); financial_ratios new_financial_ratios = new financial_ratios { Company_ID = this.CompanyID, Date = this.ReferenceDate, Effective_Tax_Rate = this.EffectiveTaxRate }; project.financial_ratios.AddOrUpdate(c => new { c.Company_ID, c.Date }, new_financial_ratios); project.SaveChanges(); regression_result new_regression_result = new regression_result { Company_ID = this.CompanyID, Date = this.ValuationDate, Beta_Period = this.BetaPeriod, Adjusted_Beta = this.LeveredBeta, Periodity = "D" }; project.regression_result.AddOrUpdate(c => new {c.Company_ID, c.Date, c.Beta_Period }, new_regression_result); project.SaveChanges(); wacc_comparable_matches new_wacc_comparable_matches = new wacc_comparable_matches { Project = ProjectID, Version = ProjectVersion, Guideline_Company = CompanyID, Reference_Date_for_Financial_Statements = ReferenceDate }; project.wacc_comparable_matches.AddOrUpdate(c => new {c.Project, c.Version, c.Guideline_Company }, new_wacc_comparable_matches); project.SaveChanges(); transaction.Complete(); } }