コード例 #1
0
 private SelectListItem[] RegisterCreditCardTypes(bool isValid)
 {
     var model = new SignUpModel();
     model.CreditCardTypes = new[]
     {
         new SelectListItem { Selected = isValid, Text = "--Select--", Value = string.Empty },
         new SelectListItem { Text = "visa", Value = "visa" },
         new SelectListItem { Text = "mastercard", Value = "mastercard" },
         new SelectListItem { Text = "discover", Value = "discover" },
         new SelectListItem { Text = "amex", Value = "amex" },
     };
     return model.CreditCardTypes;
 }
コード例 #2
0
 private SelectListItem[] RegisterCreditCardExpireYears(bool isValid)
 {
     var model = new SignUpModel();
     model.CreditCardExpireYears = new[]
     {
         new SelectListItem { Selected = isValid, Text = "--Select--", Value = string.Empty },
         new SelectListItem { Text = "2013", Value = "2013" },
         new SelectListItem { Text = "2014", Value = "2014" },
         new SelectListItem { Text = "2015", Value = "2015" },
         new SelectListItem { Text = "2016", Value = "2016" },
         new SelectListItem { Text = "2017", Value = "2017" },
         new SelectListItem { Text = "2018", Value = "2018" },
         new SelectListItem { Text = "2019", Value = "2019" },
         new SelectListItem { Text = "2020", Value = "2020" },
         new SelectListItem { Text = "2021", Value = "2021" },
         new SelectListItem { Text = "2022", Value = "2022" },
         new SelectListItem { Text = "2023", Value = "2023" },
     };
     return model.CreditCardExpireYears;
 }
コード例 #3
0
        public ActionResult SignUp(SignUpModel model)
        {
            if (ModelState.IsValid)
            {
                var email = model.Email.Trim();
                bool isExistingUser = CheckIsExistingUser(email);
                if (isExistingUser)
                {
                    ModelState.AddModelError(string.Empty, "Email already exists.");
                }
                else
                {
                    var password = model.Password.Trim();
                    var passwordConfirmation = model.ConfirmPassword.Trim();
                    var creditCardNumber = model.CreditCardNumber.Trim();
                    var creditCardCVV2 = model.CreditCardCVV2.Trim();
                    var creditCardType = model.CreditCardType.Trim();
                    var creditCardExpireMonth = model.CreditCardExpireMonth.Trim();
                    var creditCardExpireYear = model.CreditCardExpireYear.Trim();
                    bool isSuccess = Insert(email, password, passwordConfirmation, creditCardType, creditCardNumber, creditCardCVV2, creditCardExpireMonth, creditCardExpireYear);
                    if (isSuccess)
                    {
                        FormsAuthentication.SetAuthCookie(model.Email, false /* createPersistentCookie */);
                        return RedirectToAction("Index", "Home");
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, "Registration failed.");
                    }
                }
            }

            if (model.CreditCardTypes == null)
            {
                model.CreditCardTypes = RegisterCreditCardTypes(true);
            }

            if (model.CreditCardExpireMonths == null)
            {
                model.CreditCardExpireMonths = RegisterCreditCardExpireMonths(true);
            }

            if (model.CreditCardExpireYears == null)
            {
                model.CreditCardExpireYears = RegisterCreditCardExpireYears(true);
            }
            return View(model);
        }
コード例 #4
0
 private SelectListItem[] RegisterCreditCardExpireMonths(bool isValid)
 {
     var model = new SignUpModel();
     model.CreditCardExpireMonths = new[]
     {
         new SelectListItem { Selected = isValid, Text = "--Select--", Value = string.Empty },
         new SelectListItem { Text = "01", Value = "01" },
         new SelectListItem { Text = "02", Value = "02" },
         new SelectListItem { Text = "03", Value = "03" },
         new SelectListItem { Text = "04", Value = "04" },
         new SelectListItem { Text = "05", Value = "05" },
         new SelectListItem { Text = "06", Value = "06" },
         new SelectListItem { Text = "07", Value = "07" },
         new SelectListItem { Text = "08", Value = "08" },
         new SelectListItem { Text = "09", Value = "09" },
         new SelectListItem { Text = "10", Value = "10" },
         new SelectListItem { Text = "11", Value = "11" },
         new SelectListItem { Text = "12", Value = "12" },
     };
     return model.CreditCardExpireMonths;
 }
コード例 #5
0
 //
 // GET: /Account/
 public ActionResult SignUp()
 {
     var model = new SignUpModel();
     model.CreditCardTypes = RegisterCreditCardTypes(false);
     model.CreditCardType = string.Empty;
     model.CreditCardExpireMonths = RegisterCreditCardExpireMonths(false);
     model.CreditCardExpireMonth = string.Empty;
     model.CreditCardExpireYears = RegisterCreditCardExpireYears(false);
     model.CreditCardExpireYear = string.Empty;
     return View(model);
 }