public IActionResult NewInvestmentRequest([FromBody] NewInvestmentRequest request) { request.UserId = CurrentUser.Id; if (!ModelState.IsValid) { return(BadRequest(ErrorResult.GetResult(ModelState))); } var errors = managerValidator.ValidateNewInvestmentRequest(CurrentUser, request); if (errors.Any()) { return(BadRequest(ErrorResult.GetResult(errors, ErrorCodes.ValidationError))); } var result = managerService.CreateNewInvestmentRequest(request); if (!result.IsSuccess) { return(BadRequest(ErrorResult.GetResult(result))); } return(Ok(result.Data)); }
public void ValidateNewManagerAccountRequestCheckTradeServer() { const string errorMsg = "Does not find trade server"; var res1 = managerValidator.ValidateNewInvestmentRequest(applicationUser, new NewInvestmentRequest { UserId = applicationUser.Id, BrokerTradeServerId = Guid.NewGuid() }); Assert.IsTrue(res1.Any(x => x.Contains(errorMsg))); var res2 = managerValidator.ValidateNewInvestmentRequest(applicationUser, new NewInvestmentRequest { UserId = applicationUser.Id, BrokerTradeServerId = brokerTradeServer.Id }); Assert.IsTrue(!res2.Any(x => x.Contains(errorMsg))); }