Ejemplo n.º 1
0
        public ActionResult BuyBitcoin(string cardId)
        {
            if (string.IsNullOrEmpty(cardId))
            {
                return(RedirectToAction("Index", "Transfer"));
            }

            //Get the card for the passed cardId
            Card card;

            using (var db = new DiamondCircle_dbEntities())
            {
                card = db.Cards.Where(c => c.CardId == cardId).FirstOrDefault();
                if (card == null)
                {
                    return(RedirectToAction("Index", "Transfer"));
                }
            }

            //Check whether there is a credit card for that card set up
            if (!card.CreditCardId.HasValue)
            {
                //Redirect to set up a credit card
                return(RedirectToAction("Create", "CreditCard", new { CardId = cardId, redirectUrl = "BuyBitcoin,BuyBitcoin" }));
            }

            var model = new BuyBitcoinViewModel()
            {
                CardId = cardId, CreditCardMask = CardStatus.MaskCardNumber(card.CreditCard.CardNumber)
            };

            return(View());
        }
Ejemplo n.º 2
0
        public void CreateCard()
        {
            using (var atmClient = new DC.AtmService.AtmClient())
            {
                using (var cardClient = new DC.CardService.CardClient())
                {
                    var keys = atmClient.CreatePublicEncryptedPrivateKey();

                    var card = new Card();
                    card.CardId = "eeeee111";
                    var privateKey = Convert.ToBase64String(keys.EncryptedWIFPrivateKey);
                    //card.Password = Convert.ToBase64String(keys.Password);
                    card.TempPublicKey = keys.PublicKey;
                    card.DateIssued    = DateTime.Now;

                    using (var db = new DiamondCircle_dbEntities())
                    {
                        var userId = WebSecurity.CurrentUserId.ToString();
                        //card.CustomerID = db.Customers.Where(s => s.UserId == userId).SingleOrDefault().CustomerId;

                        db.Cards.Add(card);
                        db.SaveChanges();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public ActionResult TransferHistory(TransferCardViewModel cardViewModel)
        {
            var transactionHistory = new List <Transaction>();
            var verified           = false;

            using (var db = new DiamondCircle_dbEntities())
            {
                var userId = WebSecurity.CurrentUserId.ToString();
                var cards  = db.Cards.Where(s => s.Customer.UserId == userId).ToList <Card>();
                foreach (var card in cards)
                {
                    if (card.CardId == cardViewModel.CardId)
                    {
                        verified = true;
                        break;
                    }
                }

                if (verified)
                {
                    transactionHistory = db.Transactions.Where(c => c.CardId == cardViewModel.CardId).OrderByDescending(t => t.DateTime).ToList();

                    return(View(transactionHistory));
                }
            }
            return(View());
        }
Ejemplo n.º 4
0
        public List <TransferCardViewModel> GetCustomerCards()
        {
            var cards = new List <TransferCardViewModel>();

            using (var db = new DiamondCircle_dbEntities())
            {
                var customerId = Helpers.GetLoggedInCustomerId(db);

                cards = db.Cards.Where(c => c.CustomerID == customerId && (c.Status == CardStatus.ACTIVE || c.Status == CardStatus.PENDING))
                        .Select(c => new TransferCardViewModel()
                {
                    CardId = c.CardId, DateIssued = c.DateIssued, PublicKey = c.PublicKey, Status = c.Status, BalanceAUD = 0, BalanceBTC = 0
                }).ToList();

                using (var atmClient = new DC.AtmService.AtmClient())
                {
                    foreach (var card in cards)
                    {
                        try
                        {
                            if (!string.IsNullOrEmpty(card.PublicKey))
                            {
                                //card.BalanceBTC = atmClient.GetBalance(card.PublicKey, 6);
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                }
            }

            return(cards);
        }
Ejemplo n.º 5
0
        public ActionResult TransferBalance(string cardId)
        {
            var model = new TransferModel();

            model.CardId = cardId;
            string publicKey;

            using (var atmClient = new DC.AtmService.AtmClient())
            {
                using (var db = new DiamondCircle_dbEntities())
                {
                    var card = db.Cards.Where(c => c.CardId == model.CardId).First();
                    publicKey = card.PublicKey;
                }

                try
                {
                    //Check that they have sufficient funds
                    var balance = atmClient.GetBalance(publicKey, 0);
                    if (balance < model.AmountToTransferInBtc + 0.0001M)
                    {
                        ModelState.AddModelError(string.Empty, "You do not have sufficient funds to transfer bitcoins");
                        return(View(model));
                    }
                    model.Balance = balance;
                }
                catch
                {
                    //TODO: This is a temporary fix. The GetBalance needs to return a value to distinguish what the error is.
                    ModelState.AddModelError(string.Empty, "You do not have sufficient funds to do a transfer, or a previous transaction has not yet been finalised");
                    return(View(model));
                }
            }
            return(View(model));
        }
Ejemplo n.º 6
0
        public static int GetLoggedInCustomerId(DiamondCircle_dbEntities db)
        {
            var userId   = WebSecurity.CurrentUserId.ToString();
            var customer = db.Customers.Where(s => s.UserId == userId).SingleOrDefault();

            return((int)customer.CustomerId);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Charges the FiatAmount to the customer's credit card,
        /// then buys the Bitcoin amount,
        /// the records the transaction.
        /// //TODO: Store a log of the transaction steps so that refunds or rollback can occur since proper transactions are impossible here
        /// </summary>
        /// <param name="CardId"></param>
        /// <param name="BitcoinAmount"></param>
        /// <param name="Currency"></param>
        /// <param name="Amount"></param>
        /// <param name="TerminalId"></param>
        /// <returns></returns>
        public bool PayForAndBuyBitcoin(string CardId, string ToCardPublicAddress, decimal BitcoinAmount, string Currency, decimal FiatAmount, int TerminalId)
        {
            if (MakeFiatPayment(CardId, Currency, FiatAmount, TerminalId))
            {
                if (ToCardPublicAddress != "")
                {
                    DC.Data.Card card;
                    using (var db = new DiamondCircle_dbEntities())
                    {
                        card = db.Cards.Where(c => c.CardId == CardId).ToList().First();
                        ToCardPublicAddress = card.PublicKey;
                    }
                }

                DC.Node.atm atmsvc = new Node.atm();

                var order = atmsvc.CreateOrder(ToCardPublicAddress, BitcoinAmount);

                WriteTransaction(CardId, "BUY", TerminalId, Currency, "Bitcoin", BitcoinAmount, FiatAmount, order.Txn.ToString(), 1);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 8
0
 public void DeleteCard(Card card)
 {
     using (var db = new DiamondCircle_dbEntities())
     {
         db.Cards.Remove(card);
         db.SaveChanges();
     }
 }
Ejemplo n.º 9
0
        public void Commit()
        {
            var newBalance = GetBalance() - Amount;

            using (var db = new DiamondCircle_dbEntities())
            {
                var card = db.Cards.Where(c => c.CardId == _cardId).First();
                card.CardCurrencies.Where(b => b.FiatCurrencyId == CurrencyId).First().Balance = (decimal)newBalance;
                db.SaveChanges();
            }
        }
Ejemplo n.º 10
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    WebSecurity.CreateUserAndAccount(model.UserName, model.Password, null, true);

                    DbContext db = new DbContext("DefaultConnection");

                    //Add User Email Address
                    using (DiamondCircle_dbEntities dbs = new DiamondCircle_dbEntities())
                    {
                        UserDetail newuser = new UserDetail();
                        newuser.UserId = WebSecurity.GetUserId(model.UserName);
                        newuser.Email  = model.Email;
                        dbs.UserDetails.Add(newuser);
                        dbs.SaveChanges();

                        //Make sure they have a customer record created at the same time
                        Customer customer = new Customer();
                        //TODO: Converting and Int Id to a string is really messy
                        customer.UserId     = newuser.UserId.ToString();
                        customer.CreateDate = DateTime.Now;
                        dbs.Customers.Add(customer);
                        dbs.SaveChanges();
                    }


                    WebSecurity.ConfirmAccount(model.UserName);

                    //NO!  TODO:
                    //Send cofirmation email
                    string query = "select ConfirmationToken from webpages_Membership where UserId = (select UserId from UserProfile where UserName ='******')";
                    string body  = "Dear " + model.UserName + ",\n\r To activate  your username click link below: \n\r  "
                                   + string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Content("~")) + "Account/Confirm/?str=" + db.Database.SqlQuery <string>(query, model.UserName).FirstOrDefault() + " \n\r \n\r  Regards,";;

                    SendEmail.Send("Diamond Circle", model.Email, "Activation link", body);

                    TempData["Msg"] = "An activation link has been sent to your email address.";

                    return(RedirectToAction("Message", "Home"));
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Ejemplo n.º 11
0
        public ActionResult Create(CreditCard model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                using (var atmClient = new DC.CardService.CardClient())
                {
                    try
                    {
                        string cardId;

                        using (var db = new DiamondCircle_dbEntities())
                        {
                            var savedCard = db.CreditCards.Add(model);
                            db.SaveChanges();

                            //Get the DC card for this user
                            cardId = model.Cards.First().CardId;
                            var card = db.Cards.Where(c => c.CardId == cardId).First();
                            card.CreditCardId = savedCard.CreditCardId;
                            db.SaveChanges();
                        }

                        if (string.IsNullOrEmpty(returnUrl))
                        {
                            return(RedirectToAction("AddCardSuccessful", new { abbrevCardNum = MaskCardNumber(model.CardNumber) }));
                        }
                        else
                        {
                            var urlVals = returnUrl.Split(',');
                            if (urlVals.Length == 1)
                            {
                                return(RedirectToAction(urlVals[0], urlVals[1]));
                            }
                            else
                            {
                                return(RedirectToAction(returnUrl));
                            }
                        }
                    }
                    catch (ArgumentException argEx)
                    {
                        ModelState.AddModelError(string.Empty, argEx.Message);
                    }
                    catch (Exception ex)
                    {
                        ModelState.AddModelError(string.Empty, ex.Message);
                    }
                }
            }

            return(View(model));
        }
Ejemplo n.º 12
0
 protected override ValidationResult IsValid(object value, ValidationContext validationContext)
 {
     if (value != null)
     {
         string data = (string)value;
         DiamondCircle_dbEntities db = new DiamondCircle_dbEntities();
         if (db.UserDetails.Where(s => s.Email == data).Count() == 0)
         {
             return(new ValidationResult("Email does not  exist."));
         }
     }
     return(ValidationResult.Success);
 }
Ejemplo n.º 13
0
        public ActionResult TransferBalance(TransferModel model)
        {
            if (ModelState.IsValid)
            {
                using (var atmClient = new DC.AtmService.AtmClient())
                {
                    try
                    {
                        string password;
                        Card   card;

                        using (var db = new DiamondCircle_dbEntities())
                        {
                            card     = db.Cards.Where(c => c.CardId == model.CardId).First();
                            password = card.Password;
                        }

                        var transactionHash = atmClient.SendBitcoins(model.PrivateKey.Trim(), password.Trim(), model.DestinationAddress, model.AmountToTransferInBtc);
                        //var atmObj = new atm();
                        //var transactionHash = atmObj.SendBitcoins(model.PrivateKey.Trim(), password.Trim(), model.DestinationAddress, model.AmountToTransferInBtc);

                        //Store the transaction
                        //using (var db = new DiamondCircle_dbEntities())
                        //{
                        //    var sendAction = new SendBitcoin();
                        //    sendAction.CardId = model.CardId;
                        //    sendAction.Sender = card.PublicKey;
                        //    sendAction.Receiver = model.DestinationAddress;
                        //    sendAction.BTCAmount = model.AmountToTransferInBtc;
                        //    sendAction.Created = DateTime.UtcNow;
                        //    db.SendBitcoins.Add(sendAction);
                        //    db.SaveChanges();
                        //}

                        return(RedirectToAction("TransferSuccessful", new { receipt = transactionHash }));
                    }
                    catch (ArgumentException argEx)
                    {
                        ModelState.AddModelError(string.Empty, argEx.Message);
                    }
                    catch (Exception ex)
                    {
                        ModelState.AddModelError(string.Empty, "An unknown error occurred");
                    }
                }
            }

            return(View(model));
        }
Ejemplo n.º 14
0
 private decimal?GetBalance()
 {
     if (_balance == null)
     {
         using (var db = new DiamondCircle_dbEntities())
         {
             var card = db.Cards.Where(c => c.CardId == _cardId).SingleOrDefault();
             return(card.CardCurrencies.Where(b => b.FiatCurrencyId == CurrencyId).First().Balance);
         }
     }
     else
     {
         return(_balance);
     }
 }
Ejemplo n.º 15
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            if (value != null)
            {
                string data = (string)value;

                using (DiamondCircle_dbEntities db = new DiamondCircle_dbEntities())
                {
                    if (db.Cards.Where(s => s.CardId == data).Count() == 0)
                    {
                        return(new ValidationResult("Tag Id does not exist."));
                    }
                }
            }
            return(ValidationResult.Success);
        }
Ejemplo n.º 16
0
        public ActionResult Create(CreditCard model, bool buy)
        {
            if (ModelState.IsValid)
            {
                using (var atmClient = new DC.CardService.CardClient())
                {
                    try
                    {
                        string cardId;

                        using (var db = new DiamondCircle_dbEntities())
                        {
                            var savedCard = db.CreditCards.Add(model);
                            db.SaveChanges();

                            //Get the DC card for this user
                            cardId = model.Cards.First().CardId;
                            var card = db.Cards.Where(c => c.CardId == cardId).First();
                            card.CreditCardId = savedCard.CreditCardId;
                            db.SaveChanges();
                        }

                        if (buy)
                        {
                            return(RedirectToAction("BuyBitcoin", "BuyBitcoin", new { CardId = cardId }));
                        }
                        else
                        {
                            return(RedirectToAction("AddCardSuccessful", new { abbrevCardNum = MaskCardNumber(model.CardNumber) }));
                        }
                    }
                    catch (ArgumentException argEx)
                    {
                        ModelState.AddModelError(string.Empty, argEx.Message);
                    }
                    catch (Exception ex)
                    {
                        ModelState.AddModelError(string.Empty, ex.Message);
                    }
                }
            }

            return(View(model));
        }
Ejemplo n.º 17
0
        public ActionResult BuyBitcoin(string cardId)
        {
            //Get the card for the passed cardId
            Card card;

            using (var db = new DiamondCircle_dbEntities())
            {
                card = db.Cards.Where(c => c.CardId == cardId).First();
            }

            //Check whether there is a credit card for that card set up
            if (!card.CreditCardId.HasValue)
            {
                //Redirect to set up a credit card
                return(RedirectToAction("Create", "CreditCard", new { CardId = cardId, buy = true }));
            }

            return(View());
        }
Ejemplo n.º 18
0
        static void Main(string[] args)
        {
            DiamondCircle_dbEntities db = new DiamondCircle_dbEntities();

            Console.Write("Enter email or enter to skip: ");
            String email = Console.ReadLine();

            Decimal?CustomerId = null;

            if (!String.IsNullOrEmpty(email))
            {
                UserDetail profile = db.UserDetails.First(p => p.Email == email);

                String   userId   = profile.UserId.ToString();
                Customer customer = db.Customers.First(c => c.UserId == userId);
                CustomerId = customer.CustomerId;
            }

            Console.Write("Enter card id to add to database: ");
            String cardId = Console.ReadLine();

            DC.AtmService.AtmClient client = new DC.AtmService.AtmClient();
            DC.AtmService.Keys      newKey = client.CreatePublicEncryptedPrivateKey();

            Card card = new Card()
            {
                CardId     = cardId,
                PublicKey  = newKey.PublicKey,
                Password   = Convert.ToBase64String(newKey.Password),
                CustomerID = CustomerId,
                DateIssued = DateTime.UtcNow
                             //Password =  newKey.Password
            };



            db.Cards.Add(card);
            db.SaveChanges();

            Console.Write("All done.  The bitcoin address is {0}", card.PublicKey);
            Console.ReadKey();
        }
Ejemplo n.º 19
0
        public CCInfo GetCustomerCC(string CardId)
        {
            using (DiamondCircle_dbEntities db = new DiamondCircle_dbEntities())
            {
                var card = db.Cards.Where(c => c.CardId == CardId).FirstOrDefault();

                if (card == null)
                {
                    throw new InvalidOperationException("The card entered does not exist");
                }

                var creditCard = db.CreditCards.Where(cc => cc.CreditCardId == card.CreditCardId).FirstOrDefault();
                if (creditCard == null)
                {
                    throw new InvalidOperationException("This card does not have credit card details related to it.");
                }

                CCInfo ccDetails = new CCInfo()
                {
                    Address        = creditCard.AddressLine1,
                    CardHolderName = creditCard.CardHolderName,
                    CardNumber     = creditCard.CardNumber,
                    City           = creditCard.Suburb,
                    CountryName    = creditCard.CountryName,
                    CVC2           = creditCard.CVC2,
                    EmailAddress   = creditCard.EmailAddress,
                    FirstName      = creditCard.FirstName,
                    LastName       = creditCard.LastName,
                    State          = creditCard.State,
                    Telephone      = creditCard.Telephone,
                    Zip            = creditCard.Postcode,
                    DOB            = creditCard.DOB
                };

                if (creditCard.ExpiryDate.HasValue)
                {
                    ccDetails.ExpiryDate = (DateTime)creditCard.ExpiryDate;
                }

                return(ccDetails);
            }
        }
Ejemplo n.º 20
0
        private decimal CreateCustomer(string firstName, string lastName, string address, string city, string zip, string state, int countryId, string telephone, DateTime dob, string emailAddress)
        {
            using (DiamondCircle_dbEntities db = new DiamondCircle_dbEntities())
            {
                var newAddress = new DC.Data.Address()
                {
                    AddressLine1 = address, Suburb = city, Postcode = zip, CountryId = countryId, State = state, Mobile = telephone, AddressTypeId = 2
                };
                var customer = new Customer()
                {
                    CreateDate = DateTime.Today, FirstName = firstName, DOB = dob, EmailAddress = emailAddress
                };
                customer.Addresses.Add(newAddress);
                db.Customers.Add(customer);

                db.SaveChanges();
                //Check if the customerId is returned on save
                var customerId = customer.CustomerId;
                return(customerId);
            }
        }
Ejemplo n.º 21
0
        public ActionResult Forgot(ForgotModel model)
        {
            if (ModelState.IsValid)
            {
                DbContext db = new DbContext("DefaultConnection");

                using (DiamondCircle_dbEntities dbs = new DiamondCircle_dbEntities())
                {
                    var user = dbs.UserDetails.Where(s => s.Email == model.Email).FirstOrDefault();
                    if (user == null)
                    {
                        TempData["Msg"] = "Your email address does not exist in our records. We are unable to reset your password.";
                        return(RedirectToAction("Message", "Home"));
                    }
                    else
                    {
                        string query    = String.Format("select UserName from UserProfile where UserId ='{0}'", user.UserId);
                        string username = db.Database.SqlQuery <string>(query, user.UserId).FirstOrDefault();

                        RandomStringGenerator newPass = new RandomStringGenerator();
                        string NewPassword            = newPass.Create(6).Trim();

                        var token = WebSecurity.GeneratePasswordResetToken(username);
                        WebSecurity.ResetPassword(token, NewPassword);

                        string body = "Dear " + username + ",\n\r Your new password is: \n\r  " +
                                      NewPassword + " \n\r \n\r  Regards,"
                                      + " \n\r \n\r  The Diamond Circle team";


                        SendEmail.Send("Diamond Circle", model.Email, "New Password", body);
                    }
                }

                TempData["Msg"] = "A new password has been sent to your email address.";
                return(RedirectToAction("Message", "Home"));
            }
            return(View(model));
        }
Ejemplo n.º 22
0
        public ActionResult BuyBitcoin(BuyBitcoinViewModel model)
        {
            string     publicKey;
            CreditCard creditCard;

            using (var db = new DiamondCircle_dbEntities())
            {
                //Get the card
                var card = db.Cards.Where(c => c.CardId == model.CardId).First();
                publicKey = card.PublicKey;

                //Get the creditCard for this card
                creditCard = db.CreditCards.Where(c => c.CreditCardId == card.CreditCardId).First();
            }
            using (var atmClient = new DC.AtmService.AtmClient())
            {
                //TODO: Deduct credit card by converted fiat amount
                // var result = PinPaymentsCharge(creditCard)
                atmClient.CreateOrder(publicKey, model.Price);
            }
            return(View());
        }
Ejemplo n.º 23
0
        public ActionResult ConfirmBuyBitcoin_Buy(BuyBitcoinViewModel model)
        {
            string     publicKey;
            CreditCard creditCard;

            using (var db = new DiamondCircle_dbEntities())
            {
                var customerId = Helpers.GetLoggedInCustomerId(db);
                //Get the card
                var card = db.Cards.Where(c => (c.CardId == model.CardId && c.CustomerID == customerId)).First();
                publicKey = card.PublicKey;

                //Get the creditCard for this card
                creditCard = db.CreditCards.Where(c => c.CreditCardId == card.CreditCardId).First();
            }
            //TODO: Change to service reference when published
            //using (var atmClient = new DC.AtmService.AtmClient())
            var atmClient = new DCPayment.Card();

            {
                atmClient.PayForAndBuyBitcoin(model.CardId, model.BitcoinAmount, model.Currency, model.Price, 1);
            }
            return(View());
        }
Ejemplo n.º 24
0
        public ActionResult TransferBalance(TransferModel model)
        {
            if (ModelState.IsValid)
            {
                using (var atmClient = new DC.AtmService.AtmClient())
                {
                    //var atmClient = new DCNode.atm();
                    try
                    {
                        string password;
                        Card   card;

                        using (var db = new DiamondCircle_dbEntities())
                        {
                            card     = db.Cards.Where(c => c.CardId == model.CardId).First();
                            password = card.Password;
                        }

                        //Check that the private key they entered resolves to the public key on their card
                        if (card.PublicKey != atmClient.ResolvePrivateKey(model.PrivateKey.Trim(), card.Password.Trim()))
                        {
                            ModelState.AddModelError(string.Empty, "The private key you entered does not relate to the public key on this card");
                            return(View(model));
                        }

                        //Check that there are 6 confirmations
                        int confirmations = atmClient.GetConfirmations(card.PublicKey.Trim());
                        if (confirmations < 1)
                        {
                            ModelState.AddModelError(string.Empty, "Your current balance is still being verified. Your last transaction is unconfirmed. Please try again later");
                            return(View(model));
                        }
                        else if (confirmations < 6)
                        {
                            ModelState.AddModelError(string.Empty, "Your current balance has been confirmed with " + confirmations.ToString() + " out of the minimum 6 blockchain confirmations. Please try again later");
                            return(View(model));
                        }


                        //try
                        //{
                        //    //Check that they have sufficient funds
                        //    var balance = atmClient.GetBalance(card.PublicKey, 0);
                        //    if (balance < model.AmountToTransferInBtc + 0.0001M)
                        //    {
                        //        ModelState.AddModelError(string.Empty, "You do not have sufficient funds to transfer this amount");
                        //        return View(model);
                        //    }
                        //}
                        //catch
                        //{
                        //    //TODO: This is a temporary fix. The GetBalance needs to return a value to distinguish what the error is.
                        //    ModelState.AddModelError(string.Empty, "You do not have sufficient funds to transfer this amount");
                        //    return View(model);
                        //}

                        var transactionHash = atmClient.SendBitcoins(model.PrivateKey.Trim(), password.Trim(), model.DestinationAddress, model.AmountToTransferInBtc);

                        //Store the transaction
                        //using (var db = new DiamondCircle_dbEntities())
                        //{
                        //    var sendAction = new SendBitcoin();
                        //    sendAction.CardId = model.CardId;
                        //    sendAction.Sender = card.PublicKey;
                        //    sendAction.Receiver = model.DestinationAddress;
                        //    sendAction.BTCAmount = model.AmountToTransferInBtc;
                        //    sendAction.Created = DateTime.UtcNow;
                        //    db.SendBitcoins.Add(sendAction);
                        //    db.SaveChanges();
                        //}

                        return(RedirectToAction("TransferSuccessful", new { receipt = transactionHash }));
                    }
                    catch (ArgumentException argEx)
                    {
                        ModelState.AddModelError(string.Empty, argEx.Message);
                    }
                    catch (Exception ex)
                    {
                        ModelState.AddModelError(string.Empty, ex.Message);
                    }
                }
            }

            return(View(model));
        }