// GET: Souvenirs/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var souvenir = await _context.Souvenirs.FindAsync(id);

            if (souvenir == null)
            {
                return(NotFound());
            }
            var sou = new EditSouvenir();

            using (var ms = new MemoryStream())
            {
                sou.SouvenirID     = souvenir.SouvenirID;
                sou.sImage         = souvenir.SouImage;
                sou.SouQuantity    = souvenir.SouQuantity;
                sou.SouDescription = souvenir.SouDescription;
                sou.SouName        = souvenir.SouName;
                sou.SouPrice       = souvenir.SouPrice;
                sou.SupplierID     = souvenir.SupplierID;
                sou.CategoryID     = souvenir.CategoryID;
            }
            ViewData["CategoryID"] = new SelectList(_context.Categories, "CategoryID", "CategoryID", souvenir.CategoryID);
            ViewData["SupplierID"] = new SelectList(_context.Suppliers, "SupplierID", "SupplierID", souvenir.SupplierID);
            return(View(sou));
        }
        public async Task <IActionResult> Edit(int id, EditSouvenir souvenir)
        {
            if (id != souvenir.SouvenirID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var sou = new Souvenir();
                    using (var ms = new MemoryStream())
                    {
                        await souvenir.image.CopyToAsync(ms);

                        sou.SouvenirID     = souvenir.SouvenirID;
                        sou.SouImage       = ms.ToArray();
                        sou.SouQuantity    = souvenir.SouQuantity;
                        sou.SouDescription = souvenir.SouDescription;
                        sou.SouName        = souvenir.SouName;
                        sou.SouPrice       = souvenir.SouPrice;
                        sou.SupplierID     = souvenir.SupplierID;
                        sou.CategoryID     = souvenir.CategoryID;
                    }
                    _context.Update(sou);
                    await _context.SaveChangesAsync();
                }

                catch (DbUpdateConcurrencyException)
                {
                    if (!SouvenirExists(souvenir.SouvenirID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryID"] = new SelectList(_context.Categories, "CategoryID", "CategoryID", souvenir.CategoryID);
            ViewData["SupplierID"] = new SelectList(_context.Suppliers, "SupplierID", "SupplierID", souvenir.SupplierID);
            return(View(souvenir));
        }