public ActionResult <Transfer> CreateTransfer(Transfer newTransfer) { Transfer transfer = TransferDAO.CreateTransfer(newTransfer); decimal fromAccountBalance = AccountDAO.GetBalance(newTransfer.AccountFrom); decimal toAccountBalance = AccountDAO.GetBalance(newTransfer.AccountTo); bool transferSuccessful = AccountDAO.SendMoney(transfer, fromAccountBalance, toAccountBalance); return(Created($"/transfers/{transfer.TransferId}", transfer)); }
public IActionResult GetBalance() { int userId = (int)GetCurrentUserId(); double result = accountDAO.GetBalance(userId); return(Ok(result)); }
public decimal GetBalance() { int accountId = (int)GetCurrentUserId(); return(AccountDAO.GetBalance(accountId)); }
[HttpGet("balance")] // Needs to use token & Authentication public IActionResult GetBalance() { // Pull the ID out of the token. //int userIdentity = userDAO.GetUser var userID = User.FindFirst("sub")?.Value; int id = Convert.ToInt32(userID); return(Ok(accountDAO.GetBalance(id))); }
public string ProcessTheTransfer(Transfer transfer) { // should add a transaction around the sql calls string confirmationMessage = "Recipient Not Found"; decimal fromBalance = accountDAO.GetBalance(transfer.FromUserID); decimal toBalance = accountDAO.GetBalance(transfer.ToUserID); //decimal amountToTransfer = transfer.Amount; // check for valid recipient ID# List <User> validUsers = userDAO.GetUsers(); foreach (User thisUser in validUsers) { if (thisUser.UserId == transfer.ToUserID) { if (accountDAO.GetBalance(transfer.FromUserID) >= transfer.Amount) { fromBalance -= transfer.Amount; toBalance += transfer.Amount; accountDAO.UpdateBalance(transfer.FromUserID, fromBalance); accountDAO.UpdateBalance(transfer.ToUserID, toBalance); confirmationMessage = Convert.ToString(transferDAO.MakeTransfer(transfer)); } else { confirmationMessage = "Insufficient Funds"; } } //else //{ // confirmationMessage = "Recipient Not Found"; //} } // Lee is pissed cause we're aren't user friendly "enough" // Actually, it's ok. This isn't a real program. return(confirmationMessage); }
public bool TransferRequest(Transfers transfer) { if (transfer.Amount <= accountDAO.GetBalance(transfer.AccountFrom)) { return(transfersDAO.TransferRequest(transfer)); } else { return(false); } }
public decimal GetBalance() { var id = User.FindFirst("sub")?.Value; var accountId = int.Parse(id); if (accountId > 0) { return(accountDAO.GetBalance(accountId)); } return(0); }
public ActionResult <decimal> GetAccountBalance() { int currentID = int.Parse(User.FindFirst("sub").Value); decimal balance = accountDAO.GetBalance(currentID); if (balance >= 0) { return(Ok(balance)); } else { return(NotFound()); } }
public ActionResult <decimal> GetAccountBalance() { string userIDString = (User.FindFirst("sub")?.Value); int userID; bool parsedOK = Int32.TryParse(userIDString, out userID); if (!parsedOK) { return(StatusCode(500)); } decimal?balance = accountDAO.GetBalance(userID); if (balance == null) { return(NotFound()); } return(Ok(balance)); }
public ActionResult <decimal> GetBalance() { string authorizedName = User.Identity.Name; decimal userBalance = 0.00M; try { userBalance = accountDAO.GetBalance(authorizedName); if (userBalance < 0.00M) { return(NotFound("User balance is less than zero!")); } } catch (Exception ex) { return(NotFound($"Serverside Exception: {ex.Message}")); } return(Ok(userBalance)); //something }
public decimal GetBalance() { decimal accountBalance = accountDAO.GetBalance(userId); return(accountBalance); }
public ActionResult <Account> GetBalance() { Account account = accountSqlDAO.GetBalance(userId); return(account); }