Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("IdOrder,IdShose")] OrderShoe orderShoe)
        {
            if (id != orderShoe.IdShose)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(orderShoe);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderShoeExists(orderShoe.IdShose))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdOrder"] = new SelectList(_context.Order, "Id", "CardName", orderShoe.IdOrder);
            ViewData["IdShose"] = new SelectList(_context.Shoe, "Id", "Color", orderShoe.IdShose);
            return(View(orderShoe));
        }
        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"));
        }
Beispiel #3
0
        public async Task <IActionResult> Create([Bind("IdOrder,IdShose")] OrderShoe orderShoe)
        {
            if (ModelState.IsValid)
            {
                _context.Add(orderShoe);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdOrder"] = new SelectList(_context.Order, "Id", "Idcustomer", orderShoe.IdOrder);
            ViewData["IdShose"] = new SelectList(_context.Shoe, "Id", "Name", orderShoe.IdShose);
            return(View(orderShoe));
        }
Beispiel #4
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 }));
        }