Пример #1
0
        public ActionResult Debit(DebitViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                Console.WriteLine(model.DestinationAccountNumber);
                return(View(model));
            }
            if (ExisteDestino(model.DestinationAccountNumber) && HayFondos(model.DestinationAccountNumber, Convert.ToDouble(model.Amount)))
            {
                SqlConnection sqlCon = new SqlConnection(cadenaConexion);

                //Monto de cuenta destino
                SqlCommand sqlCmd3 = new SqlCommand
                {
                    CommandText = "select Balance from AspNetUsers where AccountNumber='" + model.DestinationAccountNumber + "';",
                    Connection  = sqlCon
                };

                string consultadestino = "0";

                //este mensaje nunca deberia de imprimirse
                ViewBag.Message = String.Format("Aun no he realizado la transferencia\\n{0}", DateTime.Now.ToString());
                //lo puse para probar porque la estaba cagando en algo
                try
                {
                    sqlCon.Open();
                    consultadestino = sqlCmd3.ExecuteScalar().ToString();

                    double monto         = Convert.ToDouble(model.Amount);
                    string monto_destino = Convert.ToString(Convert.ToDouble(consultadestino) - monto);

                    //Actualiza monto actual de usuario destino
                    SqlCommand usuario_destino = new SqlCommand
                    {
                        CommandText = "UPDATE AspNetUsers SET Balance='" + monto_destino + "' WHERE AccountNumber='" + model.DestinationAccountNumber + "';",
                        Connection  = sqlCon
                    };
                    usuario_destino.ExecuteNonQuery();

                    ViewBag.Message = String.Format("Transferencia realizada con exito\\n Fecha y hora: {0}", DateTime.Now.ToString());
                }
                catch
                {
                    ViewBag.Message = String.Format("La estoy cagando\\n{0}", DateTime.Now.ToString());
                }
                finally
                {
                    if (sqlCon.State == ConnectionState.Open)
                    {
                        sqlCon.Close();
                    }
                }
                return(RedirectToAction("CheckBalance", "Account"));
            }
            else
            {
                ModelState.AddModelError("", "Numero de cuenta no existe.");
                return(View(model));
            }
        }
        public async Task <IActionResult> PostDebit(string description, decimal amount)
        {
            if (!caller.Identity.IsAuthenticated)
            {
                return(BadRequest("User not authenticated"));
            }

            // retrieve the user info
            var userId        = int.Parse(caller.Claims.SingleOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value);
            var accountNumber = int.Parse(caller.Claims.SingleOrDefault(c => c.Type == "account_number").Value);
            var debit         = new DebitViewModel {
                UserId = userId, AccountNumber = accountNumber, Amount = amount, Description = description
            };

            var result = await accountAppServices.AddDebit(debit, CancellationToken.None);

            return(ValidationHandler(debit, result));
        }
Пример #3
0
        public async Task <Result> AddDebit(DebitViewModel debit, CancellationToken cancellationToken = default)
        {
            var request = mapper.Map <Commands.Debit.Request>(debit);

            return(await mediator.SendCommand(request, cancellationToken));
        }
Пример #4
0
 public WithdrawResponse(DebitViewModel transaction)
 {
     Transaction = transaction;
 }
Пример #5
0
        private void OnConfirmationCompleted(object sender, Video video)
        {
            var debitViewModel = new DebitViewModel(_facade, video);

            _facade.ViewProvider.ShowDialogModal(debitViewModel);
        }