public async Task <IActionResult> IssueMore([Bind("Id,Price,TimeOut,Amount")] IssueMoreViewModel issueMoreViewModel) { var(jwtToken, id) = JwtHelper.GetJwtAndIdFromJwt(Request); await _publicShareOwnerControlClient.IssueShares(new IssueSharesRequest { Amount = issueMoreViewModel.Amount, Owner = id }, issueMoreViewModel.Id, jwtToken); var sellRequestRequest = new SellRequestRequest { AmountOfShares = issueMoreViewModel.Amount, AccountId = id, Price = issueMoreViewModel.Price, StockId = issueMoreViewModel.Id, TimeOut = issueMoreViewModel.TimeOut }; var validationResult = await _stockShareProviderClient.SetSharesForSale(sellRequestRequest, jwtToken); if (validationResult.Valid) { return(await List()); } ViewBag.ShowErrorDialog = true; ViewBag.ErrorText = validationResult.ErrorMessage; return(View(issueMoreViewModel)); }
public async Task <IActionResult> Sell([Bind("Id,TimeOut,AmountOfShares,Price")] SellStockViewModel sellStockViewModel) { var(jwtToken, id) = JwtHelper.GetJwtAndIdFromJwt(Request); var sellRequestRequest = new SellRequestRequest { AccountId = id, AmountOfShares = sellStockViewModel.AmountOfShares, TimeOut = sellStockViewModel.TimeOut, Price = sellStockViewModel.Price, StockId = sellStockViewModel.Id }; var validationResult = await _stockShareProviderClient.SetSharesForSale(sellRequestRequest, jwtToken); if (validationResult.Valid) { return(await OwnedStockList()); } ViewBag.ShowErrorDialog = true; ViewBag.ErrorText = validationResult.ErrorMessage; return(View(sellStockViewModel)); }
public async Task <IActionResult> Create([Bind("Name,Price,TimeOut,AmountOfShares")] CreateStockViewModel createStockViewModel) { var(jwtToken, id) = JwtHelper.GetJwtAndIdFromJwt(Request); var stockRequest = new StockRequest { Name = createStockViewModel.Name, Shares = new List <Shareholder> { new Shareholder { Amount = createStockViewModel.AmountOfShares, ShareholderId = id } }, StockOwner = id }; var stockResponse = await _publicShareOwnerControlClient.PostStock(stockRequest, jwtToken); var sellRequestRequest = new SellRequestRequest { AmountOfShares = createStockViewModel.AmountOfShares, AccountId = id, Price = createStockViewModel.Price, StockId = stockResponse.Id, TimeOut = createStockViewModel.TimeOut }; var validationResult = await _stockShareProviderClient.SetSharesForSale(sellRequestRequest, jwtToken); if (validationResult.Valid) { return(await List()); } ViewBag.ShowErrorDialog = true; ViewBag.ErrorText = validationResult.ErrorMessage; return(View(createStockViewModel)); }
public async Task <ValidationResult> SetSharesForSale(SellRequestRequest sellRequestRequest, string jwtToken) { return(await PolicyHelper.ThreeRetriesAsync().ExecuteAsync(() => _stockShareRequester.BaseAddress.AppendPathSegment(_stockShareRequester.StockShareProviderPath.StockSell) .PostJsonAsync(sellRequestRequest).ReceiveJson <ValidationResult>())); }