public async Task <InvestmentStatus> GetInvestmentReturnsValueAsync() { _logger.LogDebug("PortfolioService:GetInvestmentAndReturnsValueAsync: Fetching invested value and current value"); InvestmentStatus investmentStatus = new InvestmentStatus(); await appDb.Connection.OpenAsync(); using (var cmd = appDb.Connection.CreateCommand()) { cmd.CommandText = SqlQueries.GET_INVESTMENT_RETURNS_VALUE; using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { investmentStatus.InvestmentValue = reader.GetValue(0).GetDoubleValue(); investmentStatus.CurrentValue = reader.GetValue(1).GetDoubleValue(); } } } _logger.LogDebug("PortfolioService:GetInvestmentAndReturnsValueAsync: Investment values fetched successfully"); return(investmentStatus); }
public async Task <ActionResult <InvestmentStatus> > GetInvestmentReturnsValueAsync() { _logger.LogDebug("In PortfolioController:GetInvestmentAndReturnsValueAsync"); InvestmentStatus investmentStatus = await _portfolioService.GetInvestmentReturnsValueAsync(); _logger.LogDebug("Returning from PortfolioController:GetInvestmentAndReturnsValueAsync"); return(Ok(investmentStatus)); }
public async Task InvestmentReturns_ReturnValuePass() { InvestmentStatus expectedValue = new InvestmentStatus { InvestmentValue = 1000, CurrentValue = 1500 }; var okResult = await portfolioController.GetInvestmentReturnsValueAsync(); var actualValue = (OkObjectResult)okResult.Result; expectedValue.Should().BeEquivalentTo((InvestmentStatus)actualValue.Value); }
public async Task <IEnumerable <Investment> > GetByStatus(InvestmentStatus status) { var investments = _context.Investments .Include(i => i.InvestmentRoundtrips); var result = new List <Investment>(); foreach (var investment in investments) { await _context.Entry(investment) .Reference(i => i.InvestmentStatus).LoadAsync(); if (investment.InvestmentStatus.Id == status.Id) { await _context.Entry(investment) .Reference(i => i.InvestmentType).LoadAsync(); result.Add(investment); } } return(result); }
public InvestmentReadyDomainEvent(Investment investment, Trace trace, InvestmentStatus investmentStatus) { Investment = investment ?? throw new ArgumentNullException(nameof(investment)); Trace = trace ?? throw new ArgumentNullException(nameof(trace)); InvestmentStatus = investmentStatus ?? throw new ArgumentNullException(nameof(investmentStatus)); }