Exemple #1
0
        public IActionResult DoRegist()
        {
            Dictionary <string, string> errList = new Dictionary <string, string>();
            InputData id = new InputData(Request);

            string view = "";

            if (id.DoCheckInput(errList) == 0)
            {
                if (id.DoCheckDetailsOfDate(errList) == 0)
                {
                    Regist     rg  = new Regist();
                    RegistData rd  = new RegistData();
                    int        flg = 1;
                    rd.DoRegistData(id, rg, flg);
                    ConvertObjToArray <Regist> cvtota = new ConvertObjToArray <Regist>();
                    HttpContext.Session.Set("regist", cvtota.DoConvert(rg));
                    ViewData["regist"] = rg;
                    view = "Confirm";
                }
                else
                {
                    view = "Index";
                }
            }
            else
            {
                view = "Index";
            }
            ViewData["errlist"] = errList;
            return(View(view));
        }
Exemple #2
0
        public IActionResult Check()
        {
            MsgClass mc = new MsgClass();
            string   view;

            if (Request.Form["id"].ToString().Length == 0)
            {
                mc.Msg = "type in your id";
            }
            else if (Request.Form["pass"].ToString().Length == 0)
            {
                mc.Msg = "type in your pass";
            }
            else if ((Regex.IsMatch(Request.Form["id"].ToString(), "[0-9]{5}")) == false)
            {
                mc.Msg = "invalid pass";
            }

            if (mc.Msg == null)
            {
                view = "Start";
                User     user = new User();
                LoginDao ld   = new LoginDao(int.Parse(Request.Form["id"].ToString()), Request.Form["pass"].ToString());
                switch (ld.DoCheck(user))
                {
                case 1:
                    mc.Msg = "your id does not exist";
                    break;

                case 2:
                    mc.Msg = "your pass is incorrect";
                    break;

                case 3:
                    mc.Msg = "system exception occurred";
                    break;

                default:
                    mc.Msg = "login successful";
                    ConvertObjToArray <User> cvtObjToArr = new ConvertObjToArray <User>();
                    HttpContext.Session.Set("user", cvtObjToArr.DoConvert(user));
                    ViewData["user"] = user;
                    break;
                }
            }
            else
            {
                view = "Login";
            }

            ViewData["msg"] = mc;

            return(View(view));
        }