Exemplo n.º 1
0
        public ActionResult InformationCard(UserViewModel userViewModel)
        {
            #region

            var name     = userViewModel.Name.SetNull();
            var phone    = userViewModel.Phone.SetNull();
            var usercard = userViewModel.UserCard.SetNull();
            if (string.IsNullOrEmpty(name))
            {
                ModelState.AddModelError("name", "姓名不能为空");
                return(View(userViewModel));
            }
            if (!RegexHelpers.IsCNMobileNum(phone))
            {
                ModelState.AddModelError("phone", "手机号格式错误");
                return(View(userViewModel));
            }
            if (!RegexHelpers.IsUserCard(usercard))
            {
                ModelState.AddModelError("usercard", "身份证号格式错误");
                return(View(userViewModel));
            }

            #endregion

            if (ModelState.IsValid)
            {
                var shopCarViewModel = Session["Car"] as ShopCarViewModel;
                if (shopCarViewModel != null && shopCarViewModel.CardInfo.Count != 0)
                {
                    userViewModel.SumPrice    = shopCarViewModel.UserInfo.SumPrice;
                    shopCarViewModel.UserInfo = userViewModel;

                    Session["Car"] = shopCarViewModel;
                }
                return(RedirectToAction("CheckInfoCard"));
            }
            return(View(userViewModel));
        }
Exemplo n.º 2
0
        public ActionResult InformationTicket(UserViewModel userViewModel)
        {
            #region

            var name     = userViewModel.Name.SetNull();
            var phone    = userViewModel.Phone.SetNull();
            var usercard = userViewModel.UserCard.SetNull();
            var goDate   = userViewModel.GoDate;
            if (string.IsNullOrEmpty(name))
            {
                ModelState.AddModelError("name", "姓名不能为空");
                return(View(userViewModel));
            }
            if (!RegexHelpers.IsCNMobileNum(phone))
            {
                ModelState.AddModelError("phone", "手机号格式错误");
                return(View(userViewModel));
            }
            if (!RegexHelpers.IsUserCard(usercard))
            {
                ModelState.AddModelError("usercard", "身份证号格式错误");
                return(View(userViewModel));
            }
            try
            {
                var date = Convert.ToDateTime(goDate);
                if (date.Date < DateTime.Now.Date)
                {
                    ModelState.AddModelError("goDate", "请选择正确的日期");
                    return(View(userViewModel));
                }
                if (date.Date == DateTime.Now.Date)
                {
                    if (DateTime.Now.Hour >= 8)
                    {
                        ModelState.AddModelError("goDate", "8点后不能预定当天的票");
                        return(View(userViewModel));
                    }
                }
            }
            catch
            {
                ModelState.AddModelError("goDate", "请选择正确的日期");
                return(View(userViewModel));
            }

            #endregion Ticket

            if (ModelState.IsValid)
            {
                var shopCarViewModel = Session["Car"] as ShopCarViewModel;
                if (shopCarViewModel != null && shopCarViewModel.TicketInfo.Count != 0)
                {
                    userViewModel.SumPrice    = shopCarViewModel.UserInfo.SumPrice;
                    shopCarViewModel.UserInfo = userViewModel;

                    Session["Car"] = shopCarViewModel;
                }
                return(RedirectToAction("CheckInfoTicket"));
            }
            return(View(userViewModel));
        }