Exemple #1
0
    private ReportProfitItem QueryProfit(ReportTranItem stock, DateTime queryDate)
    {
        var data = _db.StocksHistory
                   .Where(x => x.StockId == stock.StockId && x.TranDate == queryDate.ToDate())
                   .Select(x => new { x.StockId, x.ClosingPrice })
                   .First();

        var currentPrice = data.ClosingPrice;
        var currentTotal = data.ClosingPrice * stock.NumberOfShare;
        var profit       = 0m;

        if (currentTotal != 0)
        {
            profit = stock.Balance + currentTotal;
        }

        var reportProfitItem = new ReportProfitItem()
        {
            StockId    = stock.StockId,
            StockName  = stock.StockName,
            Date       = queryDate,
            StockPrice = currentPrice,
            Profit     = profit
        };

        return(reportProfitItem);
    }
Exemple #2
0
    public void ShowBalance()
    {
        var balanceInfo = new ReportTranItem
        {
            StockName = "AccountBalance",
            Balance   = _stockRepo.GetBalance()
        };

        balanceInfo.DisplayConsoleValue();
    }