private Account GetReceiverAccount(TransferRequisite requisite) { if (requisite.ToAccountId != null) { return db.Accounts.Find(requisite.ToAccountId.Value); } else { return db.FindAccount(requisite.ToAccountNumber); } }
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); }
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)); }
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" }); }