예제 #1
0
        public IEnumerable <Shoe> AddToCart(int id, string userID)
        {
            UserCart userCart = new UserCart();

            userCart.CartId    = id;
            userCart.ShoeId    = id;
            userCart.Id        = userID;
            userCart.Quantity += 1;

            _context.UserCart.Add(userCart);
            _context.SaveChanges();

            GetAllShoesFromCart(userID);
            return(shoeQuery);
        }
예제 #2
0
        public Shoe CreateShoe(string shoeName, string shoeImage, decimal price)
        {
            Shoe shoe = (from p in _context.Shoe
                         where p.ShoeId == 1
                         select p).FirstOrDefault();

            //string imagePath = @"C:\" + shoeImage;

            //byte[] imageBytes = System.IO.File.ReadAllBytes(imagePath);
            //string base64String = Convert.ToBase64String(imageBytes);
            string image = Convert.ToBase64String(shoe.ShoeImage);

            Shoe newShoe = new Shoe();

            newShoe.ShoeName  = shoeName;
            newShoe.ShoeImage = Convert.FromBase64String(image);
            newShoe.Price     = price;

            _context.Shoe.Add(newShoe);
            _context.SaveChanges();

            return(newShoe);
        }
예제 #3
0
        public IActionResult Delete(int?id)
        {
            CookieHelper cookieHelper = new CookieHelper(_httpContextAccessor, Request, Response);

            userID = cookieHelper.Get("UserID");

            var query = (from p in _storeDB.UserCart
                         where p.ShoeId == id && p.Id == userID
                         select p).FirstOrDefault();

            if (query != null)
            {
                _storeDB.UserCart.Remove(query);
                _storeDB.SaveChanges();
            }

            return(View(query));
        }