public async Task <List <T> > ListAsync() { using (var _context = new MarketAnalyzerDBContext()) { return(await _context.Set <T>().ToListAsync()); } }
public List <T> List() { using (var _context = new MarketAnalyzerDBContext()) { return(_context.Set <T>().ToList()); } }
public async Task UpdateAsync(T item) { using (var _context = new MarketAnalyzerDBContext()) { _context.Entry(item).State = EntityState.Modified; await _context.SaveChangesAsync(); } }
public void Update(T item) { using (var _context = new MarketAnalyzerDBContext()) { _context.Entry(item).State = EntityState.Modified; _context.SaveChanges(); } }
public void Create(T item) { using (var _context = new MarketAnalyzerDBContext()) { _context.Set <T>().Add(item); _context.SaveChanges(); } }
public List <Note> GetUserNotes(string userId) { var _context = new MarketAnalyzerDBContext(); var notes = _context.Notes.Where(n => n.AspNetUserId == userId).ToList(); return(notes); }
public async Task AddListAsync(List <T> items) { using (var _ctx = new MarketAnalyzerDBContext()) { await _context.Set <T>().AddRangeAsync(items); await _context.SaveChangesAsync(); } }
public async Task CreateAsync(T item) { using (var _ctx = new MarketAnalyzerDBContext()) { await _context.Set <T>().AddAsync(item); await _context.SaveChangesAsync(); } }
public async Task UpdateListAsync(List <T> items) { using (var _context = new MarketAnalyzerDBContext()) { foreach (var item in items) { _context.Entry(item).State = EntityState.Modified; } await _context.SaveChangesAsync(); } }
public List <WeightMultiplier> GetWeightMultipliers(string userId) { var _context = new MarketAnalyzerDBContext(); var weight = (from w in _context.WeightMultipliers where w.AspNetUserId == userId select new WeightMultiplier { WeightNumberRoic = w.WeightNumberRoic, WeightNumberEquity = w.WeightNumberEquity, WeightNumberEPS = w.WeightNumberEPS, WeightNumberRevenue = w.WeightNumberRevenue, WeightNumberPERatio = w.WeightNumberPERatio, WeightNumberDebtToEquity = w.WeightNumberDebtToEquity, WeightNumberAssetsToLiabilities = w.WeightNumberAssetsToLiabilities }).ToList(); return(weight); }
public CompanyDataPoco GetCompanyInfo(Guid companyId) { var _context = new MarketAnalyzerDBContext(); var companyInfo = (from a in _context.Companies where a.Id == companyId select new CompanyDataPoco { IncomeStatements = a.ExtractedIncomeStatements.ToList(), BalanceSheets = a.ExtractedBalanceSheets.ToList(), CashFlowStatements = a.ExtractedCashFlowStatements.ToList(), KeyRatios = a.ExtractedKeyRatios.ToList(), IncomeStatementTtm = a.ExtractedIncomeStatementTtms.SingleOrDefault(), CashFlowStatementTtm = a.ExtractedCashFlowStatementTtms.SingleOrDefault(), Company = a, } ).SingleOrDefault(); return(companyInfo); }
public StockValuePoco GetStockValuePerYear(Guid companyId) { var _context = new MarketAnalyzerDBContext(); var stockValue = (from k in _context.ExtractedKeyRatios where k.CompanyId == companyId join income in _context.ExtractedIncomeStatements on new { k.CompanyId, k.Year } equals new { income.CompanyId, income.Year } select new StockValueComponents { Year = k.Year, MarketCap = k.MarketCapitalization, SharesBasic = income.SharesBasic } ).OrderBy(x => x.Year).ToList(); var stockValuesPerCompany = new StockValuePoco(); stockValuesPerCompany.Components = stockValue; stockValuesPerCompany.CompanyId = companyId; return(stockValuesPerCompany); }
public List <CompanyUserTransactionsPoco> GetUserCompanyTransactions(string userId) //retorna a lista de UserTransactions para um determinado user e para uma empresa { var companiesUserTransactions = new List <CompanyUserTransactionsPoco>(); var _context = new MarketAnalyzerDBContext(); var transactionsList = new List <UserTransaction>(); var transactions = (from transactionCompany in (from userTransaction in _context.UserTransactions where userTransaction.AspNetUserId == userId join company in _context.Companies on userTransaction.CompanyId equals company.Id select new { UserTransaction = userTransaction, Company = company }).ToList() //select new { UserTransactionId = userTransaction.Id, UserTransaction} group transactionCompany by transactionCompany.Company into grouped select new CompanyUserTransactionsPoco { Company = grouped.Key, UserTransactions = grouped.Select(u => u.UserTransaction).ToList(), UserId = userId, }).ToList(); return(transactions); }
public BaseDataAccessObject() { _context = new MarketAnalyzerDBContext(); }
public List <CompanyDataPoco> GetCompaniesInfo() { var companyPocos = new List <CompanyDataPoco>(); var _context = new MarketAnalyzerDBContext(); var incomeStatements = (from a in _context.Companies select new { IncomeStatements = a.ExtractedIncomeStatements.ToList(), Company = a, } ).OrderBy(x => x.Company.Ticker).ToList(); var balanceSheets = (from a in _context.Companies select new { BalanceSheets = a.ExtractedBalanceSheets.ToList(), Company = a, }).OrderBy(x => x.Company.Ticker).ToList(); var cashFlowStatements = (from a in _context.Companies select new { CashFlowStatements = a.ExtractedCashFlowStatements.ToList(), Company = a, }).OrderBy(x => x.Company.Ticker).ToList(); var keyRatios = (from a in _context.Companies select new { KeyRatios = a.ExtractedKeyRatios.ToList(), Company = a, }).OrderBy(x => x.Company.Ticker).ToList(); var incomeStatementTtm = (from a in _context.Companies select new { IncomeStatementTtm = a.ExtractedIncomeStatementTtms.SingleOrDefault(), Company = a, }).OrderBy(x => x.Company.Ticker).ToList(); var cashFlowStatementTtm = (from a in _context.Companies select new { CashFlowStatementTtm = a.ExtractedCashFlowStatementTtms.SingleOrDefault(), Company = a, }).OrderBy(x => x.Company.Ticker).ToList(); if (incomeStatements.Count != balanceSheets.Count || balanceSheets.Count != cashFlowStatements.Count || cashFlowStatements.Count != keyRatios.Count) { throw new Exception(); } companyPocos.AddRange(incomeStatements.Select( i => new CompanyDataPoco { IncomeStatements = i.IncomeStatements })); for (var i = 0; i < incomeStatements.Count; i++) { companyPocos[i].Company = incomeStatements[i].Company; companyPocos[i].BalanceSheets = balanceSheets[i].BalanceSheets; companyPocos[i].CashFlowStatements = cashFlowStatements[i].CashFlowStatements; companyPocos[i].KeyRatios = keyRatios[i].KeyRatios; companyPocos[i].IncomeStatementTtm = incomeStatementTtm[i].IncomeStatementTtm; companyPocos[i].CashFlowStatementTtm = cashFlowStatementTtm[i].CashFlowStatementTtm; } return(companyPocos); }