public object GetData(String transactionsFile, String portfolioFile) { String transactions = transactionsFile; List <TransactionCsv> list = new List <TransactionCsv>(); List <PortfolioRecord> portfolioList = new List <PortfolioRecord>(); Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("de-DE"); Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de-DE"); using (StreamReader reader = new StreamReader(transactions)) { ////CsvReader csv = Create(reader); TransactionReader transactionReader = new TransactionReader(); string line; reader.ReadLine(); // skip header while (null != (line = reader.ReadLine())) { TransactionCsv tr = transactionReader.ReadTransaction(line); list.Add(tr); } ////list = csv.GetRecords<TransactionCsv>().ToList(); } if (!String.IsNullOrEmpty(portfolioFile) && File.Exists(portfolioFile)) { ////reader1 = new FixingReader(portfolioFile); using (StreamReader reader = new StreamReader(portfolioFile)) { PortfolioReader porfolioReader = new PortfolioReader(); string line; reader.ReadLine(); // skip header while (null != (line = reader.ReadLine())) { PortfolioRecord record = porfolioReader.Read(line); portfolioList.Add(record); } } List <TransactionCsv> finalList = new List <TransactionCsv>(); foreach (var trans in list) { PortfolioRecord match = portfolioList.FirstOrDefault(x => x.ISIN == trans.ISIN); if (match != null) { trans.CurrentValue = match.Wert / match.Anzahl; finalList.Add(trans); } } finalList.Sort((x, y) => y.Perf.CompareTo(x.Perf)); return(finalList); } else { return(list); } }
public async Task <IActionResult> Index() { var user = await AuthenticationClient.AuthenticateAsync(HttpContext.Request); return(View(new IndexViewModel { User = user, Portfolios = await PortfolioReader.ReadByUserIdAsync(user.Id) })); }
public async Task <IActionResult> Portfolio(int id) { var user = await AuthenticationClient.AuthenticateAsync(HttpContext.Request); if (!await PortfolioReader.UserOwnsPortfolio(id, user.Id)) { throw new UnauthorizedAccessException(); } return(View(new PortfolioViewModel { User = user, Portfolio = await PortfolioReader.ReadByIdAsync(id), Report = await Reporter.GenerateAsync(user.Id, id) })); }