コード例 #1
0
        public ActionResult BuyStockConfirmed(BuyStockViewModel buyStockModel)
        {
            if (ModelState.IsValid == false)
            {
                return(View("Buy", buyStockModel));
            }

            var userId         = User.Identity.GetUserId();
            var buyStockStatus = _stockService.BuyStock(userId, buyStockModel);

            if (buyStockStatus == Infrastructure.Enum.StockBuyStatus.Success)
            {
                TempData["Message"]     = "You have successfully bought stocks!";
                TempData["MessageType"] = "success";
                return(RedirectToAction("dashboard", controllerName: "home"));
            }
            else
            {
                TempData["BuyStockStatus"] = buyStockStatus;
                return(RedirectToAction("Buy", new { stockCode = buyStockModel.Code.ToLower() }));
            }
        }