// GET: Order
        public ActionResult Index()
        {
            ViewBag.ProductList = "[]";
            LineStickersManagerEntities db = new LineStickersManagerEntities();

            if (db.tblProducts.Any(m => m.ValidateDateTime >= DateTime.Now))
            {
                var _SelectItems = (from d
                                    in db.tblProducts
                                    where d.ValidateDateTime >= DateTime.Now
                                    select new {
                    Text = d.Name,
                    Value = d.ID.ToString(),
                    Description = d.Desc,
                    Price = d.Price
                }).ToList();
                ViewBag.ProductList = JsonConvert.SerializeObject(_SelectItems);
            }
            return(View("frmOrder"));
        }
Пример #2
0
        public ActionResult Login(string inputLineID, string inputPassword, string rememberMe)
        {
            string _Info = string.Empty;
            LineStickersManagerEntities db = new LineStickersManagerEntities();
            tblUser _User = (
                from user
                in db.tblUsers
                where user.LineID == inputLineID
                select user).FirstOrDefault();

            if (_User == null)
            {
                _Info = "查無使用者";
            }
            else
            {
                if (EncryptionHelper.EncryptPassword(inputPassword) == _User.Password)
                {
                    _Info = "登入成功";
                    /*Method 1*/
                    FormsAuthenticationTicket _FormsAuthenticationTicket = new FormsAuthenticationTicket(1, inputLineID, DateTime.Now, DateTime.Now.AddMinutes(30), false, inputLineID, FormsAuthentication.FormsCookiePath);
                    string     _Ticket = FormsAuthentication.Encrypt(_FormsAuthenticationTicket);
                    HttpCookie _Cookie = new HttpCookie(FormsAuthentication.FormsCookieName, _Ticket);
                    Response.Cookies.Add(_Cookie);
                    /*Method 2*/
                    //FormsAuthentication.SetAuthCookie(inputLineID, false);
                    return(RedirectToAction("Index", "Main"));
                }
                else
                {
                    _Info = "密碼錯誤";
                }
            }


            ViewBag.Info = _Info;
            return(View("frmAccount"));
        }
Пример #3
0
        public ActionResult CreateUser(tblUser user)
        {
            ViewBag.Info = string.Empty;
            if (user != null)
            {
                #region 資料驗證
                if (
                    string.IsNullOrEmpty(user.LineID) ||
                    string.IsNullOrEmpty(user.Password) ||
                    string.IsNullOrEmpty(user.Name) ||
                    string.IsNullOrEmpty(user.PhoneNumber)
                    )
                {
                    ViewBag.Info = "資料驗證錯誤!";
                    return(View("frmNewUser"));
                }
                #endregion

                LineStickersManagerEntities db = new LineStickersManagerEntities();
                if (db.tblUsers.Any(m => m.LineID == user.LineID))
                {
                    ViewBag.Info = "相同的Line ID已存在, 請登入。";
                    return(View("frmAccount"));
                }
                else
                {
                    user.Password = EncryptionHelper.EncryptPassword(user.Password);
                    user.ModiTime = DateTime.Now;
                    db.tblUsers.Add(user);
                    db.SaveChanges();
                    ViewBag.Info = "帳號註冊成功,請登入。";
                    return(View("frmAccount"));
                }
            }
            return(View("frmAccount"));
        }