コード例 #1
0
ファイル: InvestContext.cs プロジェクト: JackQinCh/Job
		public InvestAcountModel(BankAcount account)
		{
			this.account = account;
			this.cashAcount = account.CashAcounts.FirstOrDefault();
			this.retireAcount = account.RetireAcounts.FirstOrDefault();
			if (account.StockAcounts != null)
			{
				foreach(var stock in account.StockAcounts.ToList())
				{
					
					var yesterdayValue = StockAPI.getYesterdayValue(stock.Symbol);
					var tuple = StockAPI.getStockValue(stock.Symbol);
					var value = tuple.Item1;
					this.stocks.Add(new StockModel
					{
						symbol = stock.Symbol,
						name = stock.CompanyList.Name,
						type = stock.Type,
						value = value,
						change = tuple.Item2,
						yesterdayValue = yesterdayValue,
						number = stock.Number
					});
					stockSum += value * stock.Number;
					if(stock.StartDate <= DateTime.Now.AddDays(-1))
					{
						yesterdayStockSum += yesterdayValue * stock.Number;
					}
				}
			}
			sum = stockSum + cashAcount.Value + retireAcount.Value;
			yesterdaySum = yesterdayStockSum + cashAcount.Value + retireAcount.Value;
		}
コード例 #2
0
ファイル: InvestContext.cs プロジェクト: JackQinCh/Job
		public void addAcount(BankAcount account)
		{
			var model = new InvestAcountModel(account);
			Acounts.Add(model);
			cashSum += model.cashAcount != null ? model.cashAcount.Value : 0;
			retireSum += model.retireAcount != null ? model.retireAcount.Value : 0;
			stockSum += model.stockSum;
			yesterdayStockSum += model.yesterdayStockSum;
			sum = cashSum + stockSum;
			yesterdaySum = cashSum + yesterdayStockSum;
			if (account.StockAcounts != null)
			{
				foreach (var stock in account.StockAcounts.ToList())
				{
					var tuple = StockAPI.getStockValue(stock.Symbol);
					stocks.Add(new StockModel
					{
						symbol = stock.Symbol,
						name = stock.CompanyList.Name,
						type = stock.Type,
						value = tuple.Item1,
						change = tuple.Item2,
						yesterdayValue = StockAPI.getYesterdayValue(stock.Symbol),
						number = stock.Number
					});
				}
			}
		}