示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("IdProduct,Name,BasePricePerUnit,ImgFile,PdfFile,FkUnit")] Products products)
        {
            if (id != products.IdProduct)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(products);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductsExists(products.IdProduct))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FkUnit"] = new SelectList(_context.Units, "IdUnit", "Name", products.FkUnit);
            return(View(products));
        }
        public async Task <IActionResult> Edit(int id, [Bind("IdStock,FkProduct,Amount,FkStorehouse,Status")] Stocks stocks)
        {
            if (id != stocks.IdStock)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(stocks);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StocksExists(stocks.IdStock))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FkProduct"]    = new SelectList(_context.Products, "IdProduct", "Name", stocks.FkProduct);
            ViewData["FkStorehouse"] = new SelectList(_context.Storehouses, "IdStorehouse", "IdStorehouse", stocks.FkStorehouse);
            return(View(stocks));
        }
        public async Task <IActionResult> Edit(int id, [Bind("IdUnit,Name,ShortName,Status")] Units units)
        {
            if (id != units.IdUnit)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(units);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UnitsExists(units.IdUnit))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(units));
        }