示例#1
0
        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));
        }
示例#2
0
        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));
        }
示例#3
0
        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));
        }
示例#4
0
 public async Task <ValidationResult> SetSharesForSale(SellRequestRequest sellRequestRequest, string jwtToken)
 {
     return(await PolicyHelper.ThreeRetriesAsync().ExecuteAsync(() =>
                                                                _stockShareRequester.BaseAddress.AppendPathSegment(_stockShareRequester.StockShareProviderPath.StockSell)
                                                                .PostJsonAsync(sellRequestRequest).ReceiveJson <ValidationResult>()));
 }