public IActionResult Index()
        {
            ViewBag.page = "Home";

            ViewData["loginSessionId"] = HttpContext.Session.GetString("SessionId");

            Session  browseSession = new BrowseSession();
            DBTester dbTester      = new DBTester(dbcontext);


            if (Request.Cookies["sessionId"] is null)
            {
                StartBrowseSession(browseSession);
                return(RedirectToAction("Index", "Home"));
            }
            dbTester.StoreSessionId(browseSession, null, Request.Cookies["SessionId"]); //this 1 need to consider eixsting 1

            if (HttpContext.Session.GetString("username") != null)                      //used to transfer viewbag data back to view
            {
                Customer customer1 = FindCustomer(HttpContext.Session.GetString("username"));
                ViewData["CustomerName"] = customer1.FirstName + " " + customer1.LastName;
                ViewBag.CustomerName     = ViewData["CustomerName"].ToString();
                ViewData["CustomerID"]   = customer1.CustomerID;
                ViewBag.CustomerID       = ViewData["CustomerID"].ToString();
                Debug.WriteLine("This is definitely something" + (string)ViewBag.CustomerName); //Used to check does the code run to this location
            }


            return(View());
        }
        public IActionResult HomeViewIndex()
        {
            DBTester       dbtester = new DBTester(dbcontext);
            List <Product> product  = dbtester.GetProducts();

            return(PartialView("_HomePartial", product));
        }
        public IActionResult BasketIndex()
        {
            string login_check = HttpContext.Session.GetString("username");

            Debug.WriteLine("The login_check is " + login_check);
            string browsesession = Request.Cookies["sessionId"];

            Debug.WriteLine("The browsesession " + browsesession);

            DBTester dbtester = new DBTester(dbcontext);

            List <CheckoutCart> cartresultbyID = new List <CheckoutCart>();

            if (login_check != null)
            {
                cartresultbyID = dbtester.ManageDataFromCartCID(login_check);
            }
            else
            {
                cartresultbyID = dbtester.ManageDataFromCartBSI(browsesession);
            }
            if (cartresultbyID != null)
            {
                return(PartialView("_BasketPartial", cartresultbyID));
            }
            return(null);
        }
Esempio n. 4
0
    //유저 닉네임, 점수 전역변수로 받은 후 db갱신

    public void InputUserSQL() //유저 프로필 생성
    {
        string   nickName = "testuser99";
        DBTester db       = this.gameObject.AddComponent <DBTester>();

        db.sqlcmdall("insert into user_info(user_name) values('+" + nickName + "')");
    }
Esempio n. 5
0
        public async Task <IActionResult> Login(string userName, string password, [FromServices] DBTester tester)
        {
            Customer cu = tester.ValidCustomer(userName);

            password = AuthHash.GetSimpleHash(password);


            if (cu == null)
            {
                TempData["ErrorMessage"] = "true";
                return(View());
            }

            if (cu.Password == password)
            {
                HttpContext.Session.SetString("username", userName);
                return(RedirectToAction("Index"));
            }

            else
            {
                TempData["ErrorMessage"] = "true";
                return(View());
            }
        }
Esempio n. 6
0
        public JsonResult updateBasketNum()
        {
            string   sessionID = Request.Cookies["sessionId"];
            DBTester dbtester  = new DBTester(dbcontext);

            ViewBag.CartNumber = dbtester.GetBasketNumberBySessionID(sessionID);
            return(Json(new { success = true, display = ViewBag.CartNumber }));
        }
Esempio n. 7
0
    public void UpdateUserSQL() //유저 점수 갱신
    {
        DBTester db       = this.gameObject.AddComponent <DBTester>();
        string   nickName = "testuser1";
        int      score    = 101;

        db.sqlcmdall("update user_info set user_score=" + score + " where user_name=" + "'" + nickName + "'");
    }
Esempio n. 8
0
        // GET: /ProductDetail/
        public IActionResult Index(string id)
        {
            string   sessionID = Request.Cookies["sessionId"];
            DBTester dbtester  = new DBTester(dbcontext);
            Product  product   = dbtester.GetProductByID(id);

            ViewBag.CartNumber = dbtester.GetBasketNumberBySessionID(sessionID);
            return(View(product));
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            DBTester dbTester = new DBTester();

            dbTester.TestDBOperations();

            Console.ReadLine(); // To stop the console application from exiting
        }
Esempio n. 10
0
    public DataTable GetUserScoreSQL() //유저 점수 String 형태로 가져옴
    {
        string    nickName = "testuser1";
        DBTester  db       = this.gameObject.AddComponent <DBTester>();
        DataTable dt       = db.selsql("select user_score from user_info where user_name like " + "'" + nickName + "'");
        string    st       = Convert.ToString(dt.Rows[0][0]); //st에 저장

        Debug.Log("유저 점수 : " + st);
        return(dt);
    }
Esempio n. 11
0
        public IActionResult SearchUsername(string login, string password, string?cmd)
        {
            Customer customer     = dbcontext.Customers.Find(login);
            Session  loginSession = new LoginSession();
            //  var password = Utils.Crypto.Sha256(

            var key = "E546C8DF278CD5931069B522E695D4F2";//Since GUID space //

            var decrypted = Utils.Crypto.Decrypt(customer.Password, key);

            //var decrypted = Utils.Crypto.Decrypt(customer.Password, key);

            if (customer != null)
            {
                if (decrypted == password)
                {
                    HttpContext.Session.SetString("username", login);
                    Debug.WriteLine("Login is " + login);
                    HttpContext.Session.SetString("SessionId", Guid.NewGuid().ToString());
                    DBTester dbTester = new DBTester(dbcontext);

                    string sessionId = HttpContext.Session.GetString("SessionId");
                    string username  = HttpContext.Session.GetString("username");

                    dbTester.StoreSessionId(loginSession, username, sessionId);
                    ViewData["loginSessionId"] = HttpContext.Session.GetString("SessionId");
                    ViewData["CustomerName"]   = customer.FirstName + " " + customer.LastName;
                    ViewBag.CustomerName       = ViewData["CustomerName"].ToString();
                    ViewData["CustomerID"]     = login;
                    Debug.WriteLine((string)ViewBag.CustomerName);

                    Session browseSession = dbcontext.Sessions
                                            .Where(x => x.SessionID == Request.Cookies["sessionID"]).FirstOrDefault();

                    List <Cart> carts = dbcontext.Carts
                                        .Where(x => x.SessionID == browseSession.SessionID).ToList();

                    foreach (Cart cart in carts)
                    {
                        cart.CustomerID = login;
                        dbcontext.Update(cart);
                        dbcontext.SaveChanges();
                    }


                    return(RedirectToAction("Index", "Home"));
                }
            }
            Debug.WriteLine("This SearchUsername function didnt work");

            return(RedirectToAction("Index", "Login"));
        }
Esempio n. 12
0
        public IActionResult Index([FromServices] DBTester tester)
        {
            ViewData["session"]     = HttpContext.Session.GetString("username");
            ViewData["ProductData"] = tester.RetrieveProduct();

            string username = HttpContext.Session.GetString("username");

            if (username != null)
            {
                ViewBag.Auth = "true";
            }
            return(View());
        }
Esempio n. 13
0
        public IActionResult SearchProduct(String productname = null)
        {
            DBTester       dbtester = new DBTester(dbcontext);
            List <Product> product  = dbtester.GetSearchProducts(productname);

            if (product.Count != 0)
            {
                return(PartialView("_HomePartial", product));
            }
            else
            {
                return(RedirectToAction("HomeViewIndex", "Home"));
            }
        }
Esempio n. 14
0
        public IActionResult SaveComments([FromServices] DBTester tester, int productid, string comment)
        {
            string username = HttpContext.Session.GetString("username");

            ViewData["ProductData"] = tester.ProductComment(productid);

            ViewBag.Auth = "true";
            string userid = tester.GetUID(username);

            tester.CreateReviews(productid, userid, comment);

            ViewData["GetReview"] = tester.Getallreviews(productid);
            //return RedirectToAction("ProductDetails", "Home");
            return(RedirectToAction("ProductDetails", "Home", new { @productid = productid }));
        }
        public IActionResult GetDataFromCart()
        {
            ViewData["loginSessionId"] = HttpContext.Session.GetString("SessionId");

            if (HttpContext.Session.GetString("username") != null)
            {
                string   session  = Request.Cookies["SessionId"];
                DBTester dbtester = new DBTester(dbcontext);
                String   result   = dbtester.GetDataFromCart(HttpContext.Session.GetString("username"), session);
                return(new JsonResult(new { success = "Success" }));
            }
            else
            {
                return(new JsonResult(new { success = "NotLogin" }));
            }
        }
Esempio n. 16
0
        public IActionResult ProductDetails([FromServices] DBTester tester, int productid)
        {
            ViewData["session"] = HttpContext.Session.GetString("username");
            Product       product  = tester.ProductComment(productid);
            List <Review> reviews  = tester.Getallreviews(productid);
            string        username = HttpContext.Session.GetString("username");

            if (username != null)
            {
                ViewBag.Auth = "true";
            }
            ViewData["session"]     = username;
            ViewData["ProductData"] = product;
            ViewData["GetReviews"]  = reviews;
            return(View());
        }
Esempio n. 17
0
        public IActionResult StartBrowseSession(Session browseSession)
        {
            string sessionId = Guid.NewGuid().ToString();

            CookieOptions options = new CookieOptions();

            options.Expires = DateTime.Now.AddDays(10);
            Response.Cookies.Append("sessionId", sessionId, options);
            HttpContext.Session.SetString("BrowseSessionId", Guid.NewGuid().ToString());
            DBTester dbTester = new DBTester(dbcontext);

            //string sessionId = HttpContext.Session.GetString("BrowseSessionId");
            dbTester.StoreSessionId(browseSession, null, sessionId);

            return(RedirectToAction("Index"));
        }
Esempio n. 18
0
        public IActionResult Search([FromServices] DBTester tester, string keyword = "")
        {
            string username = HttpContext.Session.GetString("username");

            if (username != null)
            {
                ViewBag.Auth = "true";
            }

            List <Product> products = tester.Search(keyword);

            ViewData["ProductData"]   = products;
            ViewData["session"]       = HttpContext.Session.GetString("username");
            ViewData["Searchkeyword"] = keyword;

            return(View());
        }
Esempio n. 19
0
    public DataTable GetRankingSQL() //유저 랭킹
    {
        DBTester  db = this.gameObject.AddComponent <DBTester>();
        DataTable dt = db.selsql("SELECT" +
                                 " user_name, user_score," +
                                 " (SELECT COUNT(*) + 1 FROM user_info WHERE user_score > b.user_score) AS rank" +
                                 " FROM" +
                                 " user_info AS b" +
                                 " ORDER BY" +
                                 " rank ASC");

        /*for(int i = 0; i<10; i++)
         * {
         *      Debug.Log("유저이름 : " + Convert.ToString(dt.Rows[i][0])+" 점수 : " + Convert.ToString(dt.Rows[i][1]));
         * }*/

        return(dt);
    }
Esempio n. 20
0
    public Boolean IdCheckSQL() //유저 닉네임 중복체크
    {
        //Boolean nickCheck = true;
        string nickName = "testuser12";

        try
        {
            DBTester  db = this.gameObject.AddComponent <DBTester>();
            DataTable dt = db.selsql("select user_name FROM user_info WHERE user_name like " + "'" + nickName + "'");
            string    st = Convert.ToString(dt.Rows[0][0]); //st에 저장

            Debug.Log("중복입니다.");
            return(false);
        }
        catch (IndexOutOfRangeException e)
        {
            Debug.Log("닉네임을 생성하실 수 있습니다.");
            return(true);
        }
    }
        public ActionResult PurchaseHistory()
        {
            ViewBag.page = "PurchaseHistory";
            ViewData["loginSessionId"] = HttpContext.Session.GetString("SessionId");

            if (HttpContext.Session.GetString("username") != null) //used to transfer viewbag data back to view
            {
                Customer customer1 = FindCustomer(HttpContext.Session.GetString("username"));
                ViewData["CustomerName"] = customer1.FirstName + " " + customer1.LastName;
                ViewBag.CustomerName     = ViewData["CustomerName"].ToString();
                ViewData["CustomerID"]   = customer1.CustomerID;
                ViewBag.CustomerID       = ViewData["CustomerID"].ToString();
                //Debug.WriteLine("This is definitely something" + (string)ViewBag.CustomerName); //Used to check does the code run to this location
            }

            string              customerID = HttpContext.Session.GetString("username");
            DBTester            dbtester   = new DBTester(dbcontext);
            List <PurchaseHist> cart       = dbtester.GetCartProducts(customerID);

            return(View("PurchaseHistory", cart));
        }
Esempio n. 22
0
        public IActionResult PurchaseItem(string productlist, [FromServices] DBTester tester)
        {
            string username = HttpContext.Session.GetString("username");

            if (username == null)
            {
                TempData["notuser"] = "******";
                return(RedirectToAction("Login", "Home"));
            }

            string strgroupids = productlist.Remove(productlist.Length - 1);

            string[] arraylist = strgroupids.Split(' ').ToArray();
            string   uid       = tester.GetUID(username);
            int      count     = tester.MakeOrder(uid);

            if (count >= 1)
            {
                int orderid = tester.GetOrderQuantity();

                foreach (var pair in arraylist)
                {
                    int[] vs        = pair.Split(',').Select(n => Convert.ToInt32(n)).ToArray();
                    int   gettingid = vs[0];
                    int   quantity  = vs[1];

                    tester.InsertOrderDetail(gettingid, orderid, quantity);
                    do
                    {
                        count += tester.ProduceActivatCode(orderid, gettingid);
                        quantity--;
                    } while (quantity > 0);
                }
            }
            ViewData["session"] = username;
            return(RedirectToAction("PurchaseHistory", "Cart"));
        }
Esempio n. 23
0
 public LoginController(Shopping_Cart_DBContext db)
 {
     this.db = db;
     Tester  = new DBTester(db);
 }
Esempio n. 24
0
 public ViewCartController(Shopping_Cart_DBContext dbcontext)
 {
     this.dbcontext = dbcontext;
     dBTester       = new DBTester(dbcontext);
 }
Esempio n. 25
0
        public IActionResult PurchaseHistory([FromServices] DBTester tester)
        {
            ViewBag.Auth = "True";

            string username = HttpContext.Session.GetString("username");

            if (username == null)
            {
                TempData["notuser"] = "******";
                return(RedirectToAction("Login", "Home"));
            }

            string uid = tester.GetUID(username);

            List <Order>       orders   = tester.RetrievePurchase(uid);
            List <ProductList> products = new List <ProductList>();

            foreach (var order in orders)
            {
                int      orderid = order.Id;
                DateTime date    = order.OrderDate;

                List <OrderDetails> orderDetails = tester.GetOrderDetails(orderid);

                foreach (var od in orderDetails)
                {
                    int productid = od.ProductId;
                    int qty       = od.Quantity;

                    List <Product> info = tester.GetProduct(productid);
                    List <string>  code = tester.GetActivationCode(productid);
                    string         name;
                    string         image;
                    double         price;

                    foreach (var pro in info)
                    {
                        name  = pro.Name;
                        image = pro.Image;
                        price = pro.Price;

                        products.Add(new ProductList
                        {
                            OrderId        = orderid,
                            ProductId      = productid,
                            Name           = name,
                            Price          = price,
                            Quantity       = qty,
                            Image          = image,
                            PurchaseDate   = date.ToString("MMMM dd, yyyy"),
                            ActivationCode = code
                        });
                    }
                }
            }

            ViewBag.Auth                = "true";
            ViewData["session"]         = username;
            ViewData["PurchaseHistory"] = products;
            return(View());
        }