public ActionResult ViewUsers()
        {
            var account = new CryptoAccount();
            var details = account.GetUsers();

            return(View(details));
        }
示例#2
0
        public ListDTO <CryptoAccountDTO> AddCryptoAccount(CryptoAccount cryptoAccount)
        {
            CryptoAccount cryptoAccountExists = _context.CryptoAccount.Where(c => c.CryptoCurrencyName == cryptoAccount.CryptoCurrencyName && c.IdUser == cryptoAccount.IdUser).FirstOrDefault();

            if (cryptoAccountExists != null)
            {
                listAccounts.Items = null;
                return(listAccounts);
            }

            var crypto         = _context.Crypto.Find(cryptoAccount.IdCrypto);
            var cryptoCurrency = _context.CryptoCurrency.Where(b => b.CryptoCurrencyName == cryptoAccount.CryptoCurrencyName).FirstOrDefault();

            cryptoAccount.IdCrypto         = crypto.Id;
            cryptoAccount.IdCryptoCurrency = crypto.Id;
            cryptoAccount.Sold             = 0;

            Random rnd            = new Random();
            int    referralRandom = rnd.Next(1000000, 9999999);

            cryptoAccount.Refference = "CRYPTOAPP" + cryptoAccount.IdCryptoCurrency.ToString() + cryptoAccount.IdUser + referralRandom.ToString();

            _context.CryptoAccount.Add(cryptoAccount);
            _context.SaveChanges();

            listAccounts.Items = new List <CryptoAccountDTO>();
            var cryptoAccountReturn = _context.CryptoAccount.ToList();

            foreach (var item in cryptoAccountReturn)
            {
                var items = _mapper.Map <CryptoAccountDTO>(item);
                listAccounts.Items.Add(items);
            }
            return(listAccounts);
        }
示例#3
0
        static void Main(string[] args)
        {
            byte   numYears        = 7;
            double avgWeeklyReturn = 1.01;
            double startingBalance = 10_500;
            byte   debug           = 1;

            double bitcoinVal  = 32_700;
            double dogecoinVal = 0.01;

            int[] biWeeklyContributions = new int[] { 0, 200, 300, 400, 500, 600, 800 };

            for (int i = 0; i < 52 * numYears; i++)
            {
                bitcoinVal  *= avgWeeklyReturn;
                dogecoinVal *= avgWeeklyReturn;
            }

            if (debug > 0)
            {
                Console.WriteLine($"Bitcoin Value in {numYears + DateTime.Now.Year} {bitcoinVal:c}\nDogecoin Value {dogecoinVal:c}\n");
            }

            foreach (int contribution in biWeeklyContributions)
            {
                CryptoAccount cryptoAccount = new CryptoAccount($"Crypto{contribution}", startingBalance, avgWeeklyReturn, contribution, debug);
                cryptoAccount.EstimateValueIn(numYears);
            }
        }
        public ActionResult DeductAccount(int id, double amount)
        {
            var c = new CryptoAccount().Debit(id, amount);

            if (c)
            {
                return(Json(new { status = 200, message = "Operation Successful" }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { status = 400, message = "Operation Failed." }, JsonRequestBehavior.AllowGet));
        }
示例#5
0
        public CryptoAccountTransaction AddCryptoTransaction(CryptoAccount crypto, double amount)
        {
            var cryptoAccount = _context.CryptoAccount.Find(crypto.Id);

            cryptoAccount.Sold             = amount;
            cryptoAccount.IdCrypto         = crypto.Id;
            cryptoAccount.IdCryptoCurrency = 0;
            _context.CryptoAccountTransaction.Add(cryptoAccountTransaction);
            _context.SaveChanges();
            return(cryptoAccountTransaction);
        }
        public ActionResult ApproveVerification(int id)
        {
            var account = new AccountVerifications();
            var approve = account.SetStatus(id, VerificationStatus.APPROVED);

            if (approve)
            {
                var accId = account.GetVerification(id).CR_Account.Id;
                var acc   = new CryptoAccount().SetAccountStatus(accId, AccountStatus.APPROVED);
            }
            return(RedirectToAction(nameof(Verifications)));
        }
示例#7
0
        public CryptoAccount AddCryptoAccount(CryptoAccount cryptoAccount)
        {
            var crypto         = _context.Crypto.Find(cryptoAccount.IdCrypto);
            var cryptoCurrency = _context.CryptoCurrency.Where(b => b.CryptoCurrencyName == cryptoAccount.CryptoCurrencyName).FirstOrDefault();

            cryptoAccount.IdCrypto         = crypto.Id;
            cryptoAccount.IdCryptoCurrency = crypto.Id;
            cryptoAccount.Sold             = 0;
            _context.CryptoAccount.Add(cryptoAccount);
            _context.SaveChanges();

            return(cryptoAccount);
        }
示例#8
0
        public ActionResult WithDraw(WithdrawVm m)
        {
            if (ModelState.IsValid)
            {
                double miniAmount = 200;
                if (m.Amount < miniAmount)
                {
                    ModelState.AddModelError("", "Please Enter Amount above the minimum amount - " + miniAmount);
                }
                var acc = new CryptoAccount();
                var bal = Convert.ToDouble(acc.Get(AccountId()).CurrentCryptoBalance);
                var sym = acc.Get(AccountId()).CR_Currency.ShortCode;
                if (bal < m.Amount)
                {
                    ModelState.AddModelError("", "Sorry !, You dont Have enough balance to withdraw - Your Current Balance is " + sym + " " + bal);
                }

                if (bal >= m.Amount)
                {
                    //process the payment
                    // get maintaince fee

                    var fees = acc.GetMaintainanceFees();
                    foreach (var i in fees)
                    {
                        if (i.SmallestAmount <= (decimal?)m.Amount || i.LargestAmount <= (decimal?)m.Amount)
                        {
                            m.MaintainceFee = Convert.ToDecimal(i.Fee);
                            var w = new CryptoWithDrawRequest();
                            w.Create(new WithdrawVm()
                            {
                                AccountId           = AccountId(),
                                Amount              = m.Amount,
                                MaintainceFee       = Convert.ToDecimal(i.Fee),
                                MaintainceFeeStatus = WithDrawRequestStatus.HasNotPaidMaintainceFee.ToString(),
                                WalletId            = m.WalletId,
                            });

                            return(RedirectToAction(nameof(MaintainceSecuredPayment), new { amount = m.MaintainceFee, withdrawrequestId = w.savedId }));
                        }
                        else
                        {
                            ModelState.AddModelError("", "Please contact customer support. ");
                        }
                    }
                }
            }

            //IEnumerable<ModelError> errors = ModelState.Values.SelectMany(v => v.Errors).ToList();
            return(View(m));
        }
        public ActionResult CreditAccount(int id, double amount)
        {
            var c = new CryptoAccount().Credit(id, amount);

            if (c)
            {
                new CryptoActivities().Create(new ActivityVm()
                {
                    AccountId = id,
                    Amount    = Convert.ToDecimal(amount)
                });
                return(Json(new { status = 200, message = "Operation Successful" }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { status = 400, message = "Operation Failed." }, JsonRequestBehavior.AllowGet));
        }
示例#10
0
        public ActionResult MyAccount()
        {
            var account = new CryptoAccount().GetUser(AccountId());

            return(View(account));
        }
示例#11
0
        public ActionResult SecuredPayment(double cryptoamount)
        {
            var transaction = new CryptoTransaction();
            var account     = new CryptoAccount();
            var accountId   = AccountId();

            transaction.Create(new TransactionVm()
            {
                Status             = TransactionStatus.PENDING,
                Amount             = Convert.ToDecimal(cryptoamount),
                accountId          = AccountId(),
                CurrencyDomination = "BTC",
                TransactionType    = TransactionTypeStatus.Credit
            });
            OptionsModel options = new OptionsModel()
            {
                public_key  = GoUrlKeys.PublicKey,
                private_key = GoUrlKeys.PrivateKey,
                webdev_key  = "",
                orderID     = transaction.savedId.ToString(),
                userID      = UserId(),
                userFormat  = "COOKIE",
                //amount = 0,
                amountUSD = Convert.ToDecimal(cryptoamount),
                period    = "2 HOUR",
                language  = "en"
            };

            ViewBag.transId = transaction.savedId.ToString();
            using (Cryptobox cryptobox = new Cryptobox(options))
            {
                ViewBag.JsonUrl = cryptobox.cryptobox_json_url();
                ViewBag.Message = "";
                DisplayCryptoboxModel model = cryptobox.GetDisplayCryptoboxModel();
                if (HttpContext.Request.Form["cryptobox_refresh_"] != null)
                {
                    ViewBag.Message = "<div class='gourl_msg'>";
                    if (cryptobox.is_paid())
                    {
                        ViewBag.Message +=
                            "<div style=\"margin:50px\" class=\"well\"><i class=\"fa fa-info-circle fa-3x fa-pull-left fa-border\" aria-hidden=\"true\"></i> " +
                            Controls.localisation[model.language].MsgNotReceived.Replace("%coinName%", model.coinName)
                            .Replace("%coinNames%",
                                     model.coinLabel == "BCH" || model.coinLabel == "DASH"
                                        ? model.coinName
                                        : model.coinName + "s")
                            .Replace("%coinLabel%", model.coinLabel) + "</div>";
                        transaction.SetStatus(transaction.savedId, TransactionStatus.INPROGESS);
                    }
                    else if (cryptobox.is_processed())
                    {
                        ViewBag.Message += "<div style=\"margin:70px\" class=\"alert alert-success\" role=\"alert\"> " +
                                           (model.boxType == "paymentbox"
                                               ? Controls.localisation[model.language].MsgReceived
                                               : Controls.localisation[model.language].MsgReceived2)
                                           .Replace("%coinName%", model.coinName)
                                           .Replace("%coinLabel%", model.coinLabel)
                                           .Replace("%amountPaid%", model.amoutnPaid.ToString()) + "</div>";
                        cryptobox.set_status_processed();
                        transaction.SetStatus(transaction.savedId, TransactionStatus.SUCCESSFUL);
                    }

                    ViewBag.Message = "</div>";
                }



                return(View(model));
            }
        }
示例#12
0
        public ActionResult MakePayment(double cryptoamount)
        {
            var transaction = new CryptoTransaction();
            var account     = new CryptoAccount();
            var accountId   = AccountId();

            transaction.Create(new TransactionVm()
            {
                Status             = TransactionStatus.PENDING,
                Amount             = Convert.ToDecimal(cryptoamount),
                accountId          = accountId,
                CurrencyDomination = "BTC",
                TransactionType    = TransactionTypeStatus.Credit
            });
            OptionsModel options = new OptionsModel()
            {
                public_key  = GoUrlKeys.PublicKey,
                private_key = GoUrlKeys.PrivateKey,
                webdev_key  = "",
                orderID     = transaction.savedId.ToString(),
                userID      = UserId(),
                userFormat  = "COOKIE",
                //amount = 0,
                amountUSD = Convert.ToDecimal(cryptoamount),
                period    = "2 HOUR",
                language  = "en"
            };

            using (Cryptobox cryptobox = new Cryptobox(options))
            {
                if (cryptobox.is_paid())
                {
                    //initiate a pendint transaction

                    if (!cryptobox.is_confirmed())
                    {
                        ViewBag.message = "Thank you for order (order #" + options.orderID + ", payment #" + cryptobox.payment_id() +
                                          "). Awaiting transaction/payment confirmation";
                    }
                    else
                    {
                        if (!cryptobox.is_processed())
                        {
                            ViewBag.message = "Thank you for order (order #" + options.orderID + ", payment #" + cryptobox.payment_id() + "). Payment Confirmed<br/> (User will see this message one time after payment has been made)";
                            cryptobox.set_status_processed();
                            transaction.SetStatus(transaction.savedId, TransactionStatus.SUCCESSFUL);
                        }
                        else
                        {
                            ViewBag.message = "Thank you for order (order #" + options.orderID + ", payment #" + cryptobox.payment_id() + "). Payment Confirmed<br/> (User will see this message during " + options.period + " period after payment has been made)";
                            transaction.SetStatus(transaction.savedId, TransactionStatus.INPROGESS);
                        }
                    }
                }
                else
                {
                    ViewBag.message = "This invoice has not been paid yet";
                    transaction.SetStatus(transaction.savedId, TransactionStatus.PENDING);
                }

                DisplayCryptoboxModel model = cryptobox.GetDisplayCryptoboxModel();

                return(View(model));
            }
        }
示例#13
0
 public async Task <ActionResult <CryptoAccount> > PostCryptoAccount(CryptoAccount cryptoAccount)
 {
     _cryptoManager.AddCryptoAccount(cryptoAccount);
     return(Ok());
 }