/// <summary> /// Validate investment /// </summary> /// <param name="investment"></param> /// <returns></returns> public bool ValidateInvetsment(InvestmentOffer investment) { var config = _configurationManager.Read(); return((config.AmountFrom == null || investment.Amount >= config.AmountFrom) && (config.AmountTo == null || investment.Amount < config.AmountTo) && (config.InterestRateFrom == null || investment.InterestRate > config.InterestRateFrom) && (config.InterestRateTo == null || investment.InterestRate < config.InterestRateTo)); }
/// <summary> /// Validate investments /// </summary> /// <param name="investment"></param> /// <returns></returns> public bool ValidateInvetsment(InvestmentOffer investment) { var isValid = false; lock (_lock) { var category = _freeAmounts.Keys.Single(f => MatchCategory(f, investment.InterestRate)); if (category != null) { isValid = _freeAmounts[category] > investment.Amount; } } return(isValid); }
public async Task <ActionResult> SendInvestment(InvestmentOffer investment) { _log.Debug($"Sending a new investment {investment}"); try { investment.Id = Guid.NewGuid(); await _bus.Publish <IInvestmentOfferNew>(new { Investment = investment }); return(Ok()); } catch (Exception exp) { _log.Error(exp, $"Error while publishing new investment."); } return(StatusCode(500)); }