Esempio n. 1
0
        public async Task <IActionResult> Edit(int id, [Bind("SaledProductsId,SalesId,ProductId,SaledProductCount,TotalPrice")] SaledProducts saledProducts)
        {
            if (id != saledProducts.SaledProductsId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(saledProducts);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SaledProductsExists(saledProducts.SaledProductsId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"] = new SelectList(_context.Product, "ProductId", "ProductName", saledProducts.ProductId);
            ViewData["SalesId"]   = new SelectList(_context.Sales, "SalesId", "SalesId", saledProducts.SalesId);
            return(View(saledProducts));
        }
Esempio n. 2
0
        public IActionResult AddToSaledProducts(int SalesId)
        {
            var           userId = _context.Users.FirstOrDefault(u => u.UserName == User.Identity.Name).Id;
            var           sItem  = _context.SaledProducts.FirstOrDefault(s => s.SalesId == SalesId);
            SaledProducts item   = new SaledProducts();

            item.SalesId = SalesId;
            _context.Add(item);
            _context.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create([Bind("SaledProductsId,SalesId,ProductId,SaledProductCount,TotalPrice")] SaledProducts saledProducts)
        {
            if (ModelState.IsValid)
            {
                _context.Add(saledProducts);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"] = new SelectList(_context.Product, "ProductId", "ProductName", saledProducts.ProductId);
            ViewData["SalesId"]   = new SelectList(_context.Sales, "SalesId", "SalesId", saledProducts.SalesId);
            return(View(saledProducts));
        }