예제 #1
0
        public async Task<JsonResult> CancelReciept(int id = 0)
        {
            var receipt = BetDatabase.Receipts.Find(id);
            var tellerAccount = await BetDatabase.Accounts.SingleOrDefaultAsync(x => x.UserId == receipt.UserId);
            
            if (receipt == null)
            {
                return Json("Receipt Not Found", JsonRequestBehavior.AllowGet);
            }
            tellerAccount.AmountE = tellerAccount.AmountE - receipt.Stake;
            receipt.ReceiptStatus = -1;
            var tellerStatement = new Statement
            {
                BalBefore = tellerAccount.AmountE,
                BalAfter = tellerAccount.AmountE,
                Comment = "Ticket " + receipt.ReceiptId + " Canceling",
                Transcation = "Reciept Canceling",
                Account = User.Identity.Name
            };

            BetDatabase.Statements.Add(tellerStatement);
            BetDatabase.Receipts.AddOrUpdate();
            BetDatabase.Accounts.AddOrUpdate();
            BetDatabase.SaveChanges();
            return Json("Receipt Was Canceled", JsonRequestBehavior.AllowGet);
        }
예제 #2
0
 public async Task<JsonResult> PayReciept(int id = 0)
 {
     var msg = "";
     var receipt = await  BetDatabase.Receipts.FindAsync(id);
     if (receipt == null)
     {
         return Json("Reciept Not Found", JsonRequestBehavior.AllowGet);
     }
     if (receipt.ReceiptStatus != 3) return Json(msg, JsonRequestBehavior.AllowGet);
     receipt.ReceiptStatus = 4;
     var cashierAccount = await BetDatabase.Accounts.SingleOrDefaultAsync(t => t.UserId == User.Identity.Name);
     var balance = cashierAccount.AmountE;
     var winAmount = receipt.TotalOdds * receipt.Stake;
     if (balance > winAmount)//Make Payments
     {
         cashierAccount.DateE = DateTime.Now;
         cashierAccount.AmountE = balance - winAmount;
         var statement = new Statement
         {
             Account = cashierAccount.UserId,
             BalBefore = cashierAccount.AmountE,
             Amount = winAmount,
             BalAfter = cashierAccount.AmountE,
             Comment = "Payment of Win Ticket Number" + receipt.ReceiptId,
             Controller = cashierAccount.UserId,
             Error = false,
             Transcation = "Ticket Payment",
             Serial = Convert.ToString(receipt.ReceiptId)
         };
         BetDatabase.Receipts.AddOrUpdate(receipt);
         BetDatabase.Statements.AddOrUpdate(statement);
         BetDatabase.Accounts.AddOrUpdate(cashierAccount);
         BetDatabase.SaveChanges();
         return Json("Reciept Sucessfull", JsonRequestBehavior.AllowGet);
     }
     msg = "You have less money.please contact admin .";
     return Json(msg, JsonRequestBehavior.AllowGet);
 }
예제 #3
0
        public ActionResult AddPayment(Payment payment)
        {
            payment.PaymentDate = DateTime.Now;
            var acc = BetDatabase.Accounts.SingleOrDefault(m => m.UserId == payment.UserId);
            if (acc == null) return Json(new Notification()
            {
                Successful = false,
                Message = "An error occured, this teller account does not exist. Contact the systems administrator for help."
            }, JsonRequestBehavior.AllowGet);

            if (payment.TransType == "From Account")
            {
                acc.AmountE = acc.AmountE - payment.AmountPaid;
                var statement = new Statement
                {
                    BalBefore = acc.AmountE,
                    Amount = payment.AmountPaid,
                    Transcation = "Money Transfer",
                    StatetmentDate = DateTime.Now,
                    Account = acc.UserId,
                    Comment = "Teller Deposit",
                    BalAfter = acc.AmountE
                };
                BetDatabase.Accounts.AddOrUpdate(acc);
                BetDatabase.Statements.Add(statement);
                BetDatabase.SaveChanges();
                var managerAcc = BetDatabase.Accounts.SingleOrDefault(m => m.UserId == User.Identity.Name);
                if (managerAcc == null) return Json(new Notification()
                {
                    Successful = false,
                    Message = "An error occured, this manager account does not exist. Contact the systems administrator for help."
                }, JsonRequestBehavior.AllowGet); ;
                managerAcc.AmountE = managerAcc.AmountE + payment.AmountPaid;
                var managerStatement = new Statement
                {
                    BalBefore = acc.AmountE,
                    Amount = payment.AmountPaid,
                    Transcation = "Money Transfer",
                    StatetmentDate = DateTime.Now,
                    Account = managerAcc.UserId,
                    Comment = "Teller Transfer From " + acc.UserId + " To " + managerAcc.UserId,
                    BalAfter = acc.AmountE
                };

                BetDatabase.Accounts.AddOrUpdate(managerAcc);
                BetDatabase.Statements.Add(managerStatement);
                BetDatabase.SaveChanges();
                return Json(new Notification()
                {
                    Successful = true,
                    Message = "Payment from account was made successfully."
                }, JsonRequestBehavior.AllowGet);
            }
            else if (payment.TransType == "To Account")
            {
                acc.AmountE = acc.AmountE + payment.AmountPaid;

                var statement = new Statement
                {
                    BalBefore = acc.AmountE,
                    Amount = payment.AmountPaid,
                    Transcation = "Transfer  ",
                    StatetmentDate = DateTime.Now,
                    Account = acc.UserId,
                    Comment = "Manager Transfer To Teller",
                    BalAfter = acc.AmountE
                };

                BetDatabase.Accounts.AddOrUpdate(acc);
                BetDatabase.Statements.Add(statement);
                BetDatabase.SaveChanges();
                var managerAcc = BetDatabase.Accounts.SingleOrDefault(m => m.UserId == User.Identity.Name);

                if (managerAcc == null) return Json(new Notification
                {
                    Successful = false,
                    Message = "An error occured, this manager account does not exist. Contact the systems administrator for help."
                }, JsonRequestBehavior.AllowGet);
                managerAcc.AmountE = managerAcc.AmountE + payment.AmountPaid;
                var managerStatement = new Statement
                {
                    BalBefore = acc.AmountE,
                    Amount = payment.AmountPaid,
                    Transcation = "Money Transfer",
                    StatetmentDate = DateTime.Now,
                    Account = managerAcc.UserId,
                    Comment = "Teller Transfer From " + acc.UserId + " To " + managerAcc.UserId,
                    BalAfter = acc.AmountE
                };

                BetDatabase.Accounts.AddOrUpdate(managerAcc);
                BetDatabase.Statements.Add(managerStatement);
                BetDatabase.SaveChanges();
                return Json(new Notification()
                {
                    Successful = true,
                    Message = "Payment to account was made successfully."
                }, JsonRequestBehavior.AllowGet);
            }

            return Json(new Notification
            {
                Successful = false,
                Message = "An error occured while saving entries to the database. Contact the systems administrator for help."
            }, JsonRequestBehavior.AllowGet);
        }