Esempio n. 1
0
 private Account GetReceiverAccount(TransferRequisite requisite)
 {
     if (requisite.ToAccountId != null)
     {
         return db.Accounts.Find(requisite.ToAccountId.Value);
     }
     else
     {
         return db.FindAccount(requisite.ToAccountNumber);
     }
 }
Esempio n. 2
0
        public Message TransferPreInfo(Guid securityToken, TransferRequisite requisite)
        {
            BankUser user = GetUser(securityToken);
            Account receiver = GetReceiverAccount(requisite);
            if (receiver == null)
            {
                throw new WebFaultException<string>("Receiver account was not found", HttpStatusCode.NotFound);
            }

            Account sender = db.Accounts.Find(requisite.FromAccountId);
            if (sender == null || !user.OwnsAccount(sender))
            {
                throw new WebFaultException<string>("Sender account was not found", HttpStatusCode.NotFound);
            }

            decimal amountCharged = bank.BackConvertCurrency(sender.Currency, requisite.Currency, requisite.Amount);

            var info = new
            {
                AmountCharged = amountCharged,
                ChangeId = UserService.PasswordDistortion(receiver.Amount.ToString(), "res"),
                EnoughMoney = amountCharged >= receiver.Amount
            };

            return Json(info);
        }
Esempio n. 3
0
        public Message TransferProceed(Guid securityToken, TransferRequisite requisite)
        {
            BankUser user = GetUser(securityToken);
            Account receiver = GetReceiverAccount(requisite);
            if (receiver == null)
            {
                throw new WebFaultException<string>("Receiver account was not found", HttpStatusCode.NotFound);
            }

            Account sender = db.Accounts.Find(requisite.FromAccountId);
            if (sender == null || !user.OwnsAccount(sender))
            {
                throw new WebFaultException<string>("Sender account was not found", HttpStatusCode.NotFound);
            }
            return Json(bank.TransferMoney(user, sender, receiver, requisite.Currency, requisite.Amount));
        }
Esempio n. 4
0
 public Message TransferAccountDetails(Guid securityToken, TransferRequisite requisite)
 {
     BankUser user = GetUser(securityToken);
     Account account = GetReceiverAccount(requisite);
     if (account == null)
     {
         throw new WebFaultException<string>("Receiver account was not found", HttpStatusCode.NotFound);
     }
     return Json(new
     {
         Status = "Valid"
     });
 }