public async Task <IActionResult> Edit(int id, [Bind("MaLoai,TenLoai,TrangThai")] LoaiSP loaiSP)
        {
            if (id != loaiSP.MaLoai)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(loaiSP);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LoaiSPExists(loaiSP.MaLoai))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View("Index"));
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, [Bind("MaSP,SN,TenSP,NgaySX,MoTa,Gia,Hinh,TrangThai")] SanPham sanPham)
        {
            if (id != sanPham.MaSP)
            {
                return(NotFound());
            }

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