Exemplo n.º 1
0
        public async Task <ActionResult <LoaiSPModels> > PostLoaiSPModels(LoaiSPModels loaiSPModels)
        {
            _context.LoaiSanPham.Add(loaiSPModels);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetLoaiSPModels", new { id = loaiSPModels.MaLoai }, loaiSPModels));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PutLoaiSPModels(int id, LoaiSPModels loaiSPModels)
        {
            if (id != loaiSPModels.MaLoai)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> Edit(int id, [Bind("MaLoai,Ten,TT,MaNCC")] LoaiSPModels loaiSPModels)
        {
            if (id != loaiSPModels.MaLoai)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(loaiSPModels);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LoaiSPModelsExists(loaiSPModels.MaLoai))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MaNCC"] = new SelectList(_context.NCC, "ID", "ID", loaiSPModels.MaNCC);
            return(View(loaiSPModels));
        }
        public async Task <IActionResult> Create([Bind("MaLoai,Ten,TT,MaNCC")] LoaiSPModels loaiSPModels)
        {
            if (ModelState.IsValid)
            {
                _context.Add(loaiSPModels);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MaNCC"] = new SelectList(_context.NCC, "ID", "ID", loaiSPModels.MaNCC);
            return(View(loaiSPModels));
        }