Exemplo n.º 1
0
        public ActionResult Withdraw()
        {
            try
            {
                if (Session["UserID"] != null)
                {
                    WithdrawVM w = new WithdrawVM();
                    w.UserID    = Convert.ToInt32(Session["UserID"]);
                    w.UserName  = Session["UserName"].ToString();
                    w.UserScore = Convert.ToInt32(Session["UserScore"]);

                    return(View(w));
                }
            }catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(RedirectToAction("SignIn"));
        }
        public async Task <IActionResult> Withdraw([FromBody] WithdrawVM withdrawVM)
        {
            try
            {
                var result = await _accountService.Withdraw(withdrawVM.AccountId, withdrawVM.Amount);

                return(result.Success
                    ? new ObjectResult(result.Data)
                    : new ObjectResult(result.ErrorMessage)
                {
                    StatusCode = StatusCodes.Status500InternalServerError
                });
            }
            catch (Exception ex)
            {
                _logger.LogCritical(ex.Message());
                return(new ObjectResult($"{nameof(Withdraw)}-{nameof(AccountController)} request failed.")
                {
                    StatusCode = StatusCodes.Status500InternalServerError
                });
            }
        }
Exemplo n.º 3
0
        public ActionResult Withdraw(WithdrawVM vM)
        {
            try
            {
                if (Session["UserName"] != null)
                {
                    Withdraw withdraw = new Withdraw();

                    withdraw.UserID = Convert.ToInt32(Session["UserID"]);
                    withdraw.phone  = Session["UserPhone"].ToString();
                    withdraw.date   = DateTime.Now;
                    withdraw.amount = vM.PointsToWithdraw;

                    db.Withdraws.Add(withdraw);

                    return(RedirectToAction("Index"));
                }
            }catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(View());
        }