public async Task <IActionResult> Create([Bind("Id,Manag,Name,Mail,City,Phone,password")] Users users)
        {
            if (ModelState.IsValid)
            {
                _context.Add(users);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(users));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Amount,Category,Type,Description,Price,NewPrice,Size,Size2,Size3,Size4,Size5,Size6,Size7,Size8,Size9,Size10,Colors,Colors2,Colors3,Colors4,Time,NumOfSale,OnSale,Pictures,Pictures2,Pictures3,Pictures4,Pictures5")] Products products)
        {
            if (ModelState.IsValid)
            {
                _context.Add(products);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(products));
        }
        public async Task <IActionResult> Create([Bind("Id,ProductId,NewOrderId")] ProductsNewOrder productsNewOrder)
        {
            if (ModelState.IsValid)
            {
                _context.Add(productsNewOrder);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["NewOrderId"] = new SelectList(_context.NewOrder, "Id", "CW", productsNewOrder.NewOrderId);
            ViewData["ProductId"]  = new SelectList(_context.Products, "Id", "Category", productsNewOrder.ProductId);
            return(View(productsNewOrder));
        }
 public async Task<IActionResult> Create([Bind("Id,UserId,CreditNum,ExpireMonth,ExpireYear,OwnName,IdNum,CW")] NewOrder newOrder)
 {
     if (ModelState.IsValid)
     {
         _context.Add(newOrder);
         await _context.SaveChangesAsync();
         string cart = HttpContext.Session.GetString("cart");
         string[] productIdscart = cart.Split(",", StringSplitOptions.RemoveEmptyEntries);
         foreach (var id in productIdscart)
         {
             ProductsNewOrder po = new ProductsNewOrder();
             po.ProductId = int.Parse(id);
             po.NewOrderId = newOrder.Id;
       
             _context.Add(po);
             
         }
         await _context.SaveChangesAsync();
         HttpContext.Session.SetString("Cart", "");
         return RedirectToAction(nameof(Index));
     }
     return View(newOrder);
 }
Example #5
0
        public async Task <IActionResult> Create([Bind("Id,UserId,CreditNum,ExpireMonth,ExpireYear,OwnName,IdNum,CW")] Pay pay)
        {
            if (HttpContext.Session.GetString("user") == null)
            {
                return(RedirectToAction("Index", "User"));
            }
            if (ModelState.IsValid)
            {
                _context.Add(pay);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(pay));
        }