public EditProfileViewModel()
 {
     AccountInfoViewModel = new AccountInfoViewModel();
     CreditCards = new HashSet<CreateCreditCardViewModel>();
     CreateCreditCardViewModel = new CreateCreditCardViewModel();
     ResetPasswordViewModel = new ResetPasswordViewModel();
 }
Пример #2
0
        public ActionResult EnterCreditCard(CreateCreditCardViewModel vm, FormCollection form)
        {
            var name = form["NameOnCard"];
            var number = form["CardNumber"];
            var expMonth = form["Month"];
            var expYear = form["Year"];
            string lastFour = "******" + number.Last(4);
            Member member = new Member();

            string encryptedCardNumber = Security.EncryptCreditCard(number, "secretAgent007");

            if (ModelState.IsValid)
            {
                using (db)
                {
                    member = db.Members.FirstOrDefault(m => m.DisplayName == User.Identity.Name);
                    member.MemberDetails.CreditCards.Add(
                    new CreditCard()
                    {
                        CardholderName = name,
                        CardNumber = encryptedCardNumber,
                        ExpirationMonth = expMonth,
                        ExpirationYear = expYear,
                        LastFour = lastFour
                    });

                    try
                    {
                        db.MemberDetails.AddOrUpdate(member.MemberDetails);
                        db.SaveChanges();
                        TempData["toast"] = "<script> $(document).ready(function () {" +
                                "toastr.options = { 'positionClass': 'toast-bottom-right' };" +
                                "toastr.success('Credit card was added successfully to your account!');});</script>";
                    }
                    catch (Exception e)
                    {
                        TempData["toast"] = "<script> $(document).ready(function () {" +
                                "toastr.options = { 'positionClass': 'toast-bottom-right' };" +
                                "toastr.error(' There was an error adding your credit card info to your account. Please try again.');});</script>";
                    }
                }
            }

            return RedirectToAction("AddressAndPayment", "Checkout");
        }
Пример #3
0
        public ActionResult EnterCreditCard()
        {
            var model = new CreateCreditCardViewModel();

            var list = GetDropDownItems();

            ViewBag.Year = list[5];
            ViewBag.Month = list[6];

            return View(model);
        }