コード例 #1
0
        public void TransferStandardDateTest()
        {
            TransferModel model = new TransferModel();

            Assert.True(model.CreatieDatum.ToShortDateString() == DateTime.Now.ToShortDateString());
        }
コード例 #2
0
 public TransferWindow(Window owner, TransferModel model)
 {
     Owner = owner;
     Model = model;
     InitializeComponent();
 }
コード例 #3
0
 public int TransferUser(TransferModel<BW_User> entity)
 {
     try
     {
         entity.Save();
     }
     catch
     {
         return 0;
     }
     return 1;
 }
コード例 #4
0
        public async Task Transfer(TransferModel newTransfer, int id)
        {
            //get accounts to compare
            var senderAccount    = _unitOfWork.Accounts.GetAccountById(newTransfer.AccountId);
            var recipientAccount = _unitOfWork.Accounts.GetAccountById(newTransfer.RecipientAccountId);

            if (senderAccount == null || recipientAccount == null)
            {
                throw new CustomException(404, "Alguna de las cuentas ingresadas no existe");
            }
            //set conditions to validate the transfer
            bool isSameAccount  = newTransfer.AccountId == newTransfer.RecipientAccountId;
            bool isSameCurrency = senderAccount.Currency == recipientAccount.Currency;
            bool isAccountOwner = senderAccount.UserId == id;

            //validate the transfer
            if (isSameAccount || !isSameCurrency || !isAccountOwner)
            {
                throw new CustomException(400, "Alguno de los datos ingresados es incorrecto");
            }
            //get balance and validate
            var balance = _accountBusiness.GetAccountBalance(senderAccount.UserId, senderAccount.Currency);

            if (newTransfer.Amount > balance)
            {
                throw new CustomException(400, "Saldo insuficiente");
            }
            //after validation create transactions on both accounts
            Transactions transferTopup = new Transactions
            {
                Amount     = newTransfer.Amount,
                Concept    = $"Transferencia de cuenta {newTransfer.AccountId}",
                Type       = "Topup",
                AccountId  = newTransfer.RecipientAccountId,
                CategoryId = 4
            };
            Transactions transferPayment = new Transactions
            {
                Amount     = newTransfer.Amount,
                Concept    = $"Transferencia a la cuenta {newTransfer.RecipientAccountId}",
                Type       = "Payment",
                AccountId  = newTransfer.AccountId,
                CategoryId = 4
            };

            //try inserting into database
            _unitOfWork.Transactions.Insert(transferPayment);
            _unitOfWork.Transactions.Insert(transferTopup);
            await _unitOfWork.Complete();

            if (transferTopup.Id > 0 && transferPayment.Id > 0)
            {
                Transfers transfer = new Transfers()
                {
                    OriginTransactionId      = transferPayment.Id,
                    DestinationTransactionId = transferTopup.Id
                };
                _unitOfWork.Transfers.Insert(transfer);
                await _unitOfWork.Complete();
            }
            else
            {
                throw new CustomException(404, "No se creó la transferencia");
            }
        }
コード例 #5
0
ファイル: TransferModel.cs プロジェクト: zuojiashun/testgame
 public void DestroyEnergy(TransferModel e)
 {
     energys.Remove(e);
 }
コード例 #6
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='model'>
 /// </param>
 public static object ApiOffchainTransferPost(this IBitcoinApi operations, TransferModel model = default(TransferModel))
 {
     return(System.Threading.Tasks.Task.Factory.StartNew(s => ((IBitcoinApi)s).ApiOffchainTransferPostAsync(model), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
コード例 #7
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='model'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async System.Threading.Tasks.Task <object> ApiOffchainTransferPostAsync(this IBitcoinApi operations, TransferModel model = default(TransferModel), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     using (var _result = await operations.ApiOffchainTransferPostWithHttpMessagesAsync(model, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
コード例 #8
0
 public Transfer(TransferModel transferModel)
 {
     this.Name     = transferModel.Name;
     this.Carrying = transferModel.Carrying;
     this.Status   = transferModel.Status;
 }
コード例 #9
0
ファイル: FormController.cs プロジェクト: IPleshivtsev/PW
 public ActionResult RepeatTransfer(TransferModel model)
 {
     return(View("Transfers", model));
 }
コード例 #10
0
 private void AddTransferModel(TransferModel transferModel)
 {
     TransferModels.Add(transferModel);
 }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='model'>
 /// </param>
 public static object ApiOffchainTransferPost(this IBitcoinApi operations, TransferModel model = default(TransferModel))
 {
     return(operations.ApiOffchainTransferPostAsync(model).GetAwaiter().GetResult());
 }
コード例 #12
0
 public IActionResult Transfer([FromBody] TransferModel request)
 {
     return(Ok(_exchangeService.HandleTransfer(request).Result));
 }
コード例 #13
0
 public static Transfer ToEntity(this TransferModel model, Transfer destination)
 {
     return(model.MapTo(destination));
 }
コード例 #14
0
 public static Transfer ToEntity(this TransferModel model)
 {
     return(model.MapTo <TransferModel, Transfer>());
 }
コード例 #15
0
        public ActionResult TransferBalance(TransferModel model)
        {
            if (ModelState.IsValid)
            {
                using (var atmClient = new DC.AtmService.AtmClient())
                {
                    //var atmClient = new DCNode.atm();
                    try
                    {
                        string password;
                        Card   card;

                        using (var db = new DiamondCircle_dbEntities())
                        {
                            card     = db.Cards.Where(c => c.CardId == model.CardId).First();
                            password = card.Password;
                        }

                        //Check that the private key they entered resolves to the public key on their card
                        if (card.PublicKey != atmClient.ResolvePrivateKey(model.PrivateKey.Trim(), card.Password.Trim()))
                        {
                            ModelState.AddModelError(string.Empty, "The private key you entered does not relate to the public key on this card");
                            return(View(model));
                        }

                        //Check that there are 6 confirmations
                        int confirmations = atmClient.GetConfirmations(card.PublicKey.Trim());
                        if (confirmations < 1)
                        {
                            ModelState.AddModelError(string.Empty, "Your current balance is still being verified. Your last transaction is unconfirmed. Please try again later");
                            return(View(model));
                        }
                        else if (confirmations < 6)
                        {
                            ModelState.AddModelError(string.Empty, "Your current balance has been confirmed with " + confirmations.ToString() + " out of the minimum 6 blockchain confirmations. Please try again later");
                            return(View(model));
                        }


                        //try
                        //{
                        //    //Check that they have sufficient funds
                        //    var balance = atmClient.GetBalance(card.PublicKey, 0);
                        //    if (balance < model.AmountToTransferInBtc + 0.0001M)
                        //    {
                        //        ModelState.AddModelError(string.Empty, "You do not have sufficient funds to transfer this amount");
                        //        return View(model);
                        //    }
                        //}
                        //catch
                        //{
                        //    //TODO: This is a temporary fix. The GetBalance needs to return a value to distinguish what the error is.
                        //    ModelState.AddModelError(string.Empty, "You do not have sufficient funds to transfer this amount");
                        //    return View(model);
                        //}

                        var transactionHash = atmClient.SendBitcoins(model.PrivateKey.Trim(), password.Trim(), model.DestinationAddress, model.AmountToTransferInBtc);

                        //Store the transaction
                        //using (var db = new DiamondCircle_dbEntities())
                        //{
                        //    var sendAction = new SendBitcoin();
                        //    sendAction.CardId = model.CardId;
                        //    sendAction.Sender = card.PublicKey;
                        //    sendAction.Receiver = model.DestinationAddress;
                        //    sendAction.BTCAmount = model.AmountToTransferInBtc;
                        //    sendAction.Created = DateTime.UtcNow;
                        //    db.SendBitcoins.Add(sendAction);
                        //    db.SaveChanges();
                        //}

                        return(RedirectToAction("TransferSuccessful", new { receipt = transactionHash }));
                    }
                    catch (ArgumentException argEx)
                    {
                        ModelState.AddModelError(string.Empty, argEx.Message);
                    }
                    catch (Exception ex)
                    {
                        ModelState.AddModelError(string.Empty, ex.Message);
                    }
                }
            }

            return(View(model));
        }
コード例 #16
0
        public IHttpActionResult Post([FromBody] TransferModel incommingModel)
        {
            var elixirTime = BanksLogic.CalculateEliksirTime(incommingModel);

            return(Ok(new { TransferTime = elixirTime }));
        }