Exemple #1
0
        public async Task <IActionResult> PutLoaiSP(int id, [FromBody] LoaiSP loaiSP)
        {
            if (id != loaiSP.MaLoai)
            {
                return(BadRequest());
            }

            _context.Entry(loaiSP).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LoaiSPExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> Create([Bind("MaLoai,TenLoai,TrangThai")] LoaiSP loaiSP)
        {
            if (ModelState.IsValid)
            {
                _context.Add(loaiSP);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View("Index"));
        }
Exemple #3
0
        public async Task <IActionResult> Create([Bind("MaSP,SN,TenSP,NgaySX,MoTa,Gia,Hinh,TrangThai")] SanPham sanPham)
        {
            if (ModelState.IsValid)
            {
                _context.Add(sanPham);
                await _context.SaveChangesAsync();

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