예제 #1
0
        public async Task <IActionResult> Create([Bind("Id,CustomerId,CardIdNumber,CardName,ExpiryDate,SecurityCode")] Order order)
        {
            if (ModelState.IsValid)
            {
                order.CustomerId = int.Parse(HttpContext.Session.GetString("user"));
                _context.Add(order);
                await _context.SaveChangesAsync();


                string   cart       = HttpContext.Session.GetString("cart");
                string[] productIds = cart.Split(",", StringSplitOptions.RemoveEmptyEntries);
                foreach (var id in productIds)
                {
                    OrderShoe po = new OrderShoe();
                    po.IdShose = int.Parse(id);
                    po.IdOrder = order.Id;
                    _context.Add(po);
                    await _context.SaveChangesAsync();
                }

                await _context.SaveChangesAsync();

                HttpContext.Session.SetString("cart", "");
                return(RedirectToAction("Index", "Home"));
            }
            //return View(order);
            return(RedirectToAction("Index", "Home"));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("Id,Name,Color,Price,ProductDescription,Img,Views,Size,Category")] Shoe shoe)
        {
            if (ModelState.IsValid)
            {
                _context.Add(shoe);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["thisUser"] = HttpContext.Session.GetString("user");
            return(View(shoe));
        }
예제 #3
0
        public async Task <IActionResult> SetForOrder([Bind("HttpContext.Session.GetString('user')", "shoe.IdShose")] OrderShoe orderShoe, Shoe shoe)
        {
            //OrderShoe orderShoe = new OrderShoe(HttpContext.Session.GetString("user"),shoe.Id);
            //OrderShoe orderShoe = new OrderShoe();
            orderShoe.IdOrder.Equals(HttpContext.Session.GetString("user"));
            orderShoe.IdShose.Equals(shoe.Id);

            if (ModelState.IsValid)
            {
                _context.Add(orderShoe);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            Shoe MyShoeId = TempData["ShoeId"] as Shoe;

            //ViewData["IdOrder"] = HttpContext.Session.GetString("user");
            //ViewData["IdShose"] = shoe.Id;
            ViewData["IdOrder"] = new SelectList(_context.Order, "Id", "Idcustomer", orderShoe.IdOrder);
            ViewData["IdShose"] = new SelectList(_context.Shoe, "Id", "Name", orderShoe.IdShose);
            //return RedirectToAction("Details/" + shoe.Id.ToString(), "Shoes");

            return(RedirectToAction("Details", "Store", new { shoeId = shoe.Id }));
        }
예제 #4
0
        public async Task <IActionResult> Create([Bind("Id,FullName,City,Country,Street,HouseNumber,Mail,Password,Order")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                HttpContext.Session.SetString("user", customer.Id.ToString());
                string id      = HttpContext.Session.GetString("cart");
                string afterId = id.Replace(",", "");
                int    newId   = Int32.Parse(afterId);
                return(RedirectToAction("Details", "Shoes", new { id = newId }));
            }
            else
            {
                ViewData["MissingInformation"] = "חסרים פרטים חשובים ברישום";
            }
            return(View(customer));
        }