public async Task <ActionResult <Bacluong> > PostBacluong(Bacluong bacluong) { _context.Bacluong.Add(bacluong); await _context.SaveChangesAsync(); return(CreatedAtAction("GetBacluong", new { id = bacluong.MaBac }, bacluong)); }
public async Task <IActionResult> Edit(string id, [Bind("BlMa,BlTen")] Bacluong bacluong) { if (id != bacluong.BlMa) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(bacluong); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BacluongExists(bacluong.BlMa)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(bacluong)); }
public async Task <IActionResult> PutBacluong(int id, Bacluong bacluong) { if (id != bacluong.MaBac) { return(BadRequest()); } _context.Entry(bacluong).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BacluongExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("BlMa,BlTen")] Bacluong bacluong) { if (ModelState.IsValid) { _context.Add(bacluong); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(bacluong)); }