public async Task <ActionResult <CumRapModel> > PostCumRapModel(CumRapModel cumRapModel) { _context.tb_CumRap.Add(cumRapModel); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCumRapModel", new { id = cumRapModel.Id }, cumRapModel)); }
public async Task <bool> Edit(int id, [Bind("Id,TenCum,TrangThai")] CumRapModel cumRapModel) { if (id != cumRapModel.Id) { return(false); } if (ModelState.IsValid) { try { _context.Update(cumRapModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CumRapModelExists(cumRapModel.Id)) { return(false); } else { throw; } } return(true); } return(false); }
public async Task <IActionResult> PutCumRapModel(int id, CumRapModel cumRapModel) { if (id != cumRapModel.Id) { return(BadRequest()); } _context.Entry(cumRapModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CumRapModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <bool> Create([Bind("Id,TenCum,TrangThai")] CumRapModel cumRapModel) { cumRapModel.TrangThai = true; if (ModelState.IsValid) { _context.Add(cumRapModel); await _context.SaveChangesAsync(); return(true); } return(false); }
// GET: Admin/CumRapModels public async Task <IActionResult> Index(int?id, string?s_name) { CumRapModel cumRap = null; if (id != null) { cumRap = await _context.tb_CumRap.FirstOrDefaultAsync(m => m.Id == id); } if (s_name != null) { ViewBag.lstCumRap = (from p in _context.tb_CumRap where p.TenCum.IndexOf(s_name) >= 0 && p.TrangThai == true select p).ToList(); } else { ViewBag.lstCumRap = (from l in _context.tb_CumRap where l.TrangThai == true select l).ToList(); } return(View(cumRap)); }