コード例 #1
0
        public ActionResult NewPositionPartial()
        {
            var token = ((ClaimsPrincipal)HttpContext.User).FindFirst("AccessToken").Value;
            var model = new NewPositionViewModel();

            model.AddStocks(token);

            return(PartialView("PartialViews/NewPosition", model));
        }
コード例 #2
0
        public ActionResult OpenPosition(NewPositionViewModel model)
        {
            var token       = ((ClaimsPrincipal)HttpContext.User).FindFirst("AccessToken").Value;
            var realBalance = ApiClient.GetSelfRealBalance(token);
            var price       = ApiClient.GetStockPrice(token, model.SelectedStockId) * model.Quantity;

            if (price > realBalance)
            {
                ModelState.AddModelError("Estimate", "Not enough money.");
                model.Success = false;
            }

            ApiClient.OpenPosition(token, model);
            model.AddStocks(token);

            return(PartialView("PartialViews/NewPosition", model));
        }