public async Task <ActionResult <LoaiPhimModel> > PostLoaiPhimModel(LoaiPhimModel loaiPhimModel) { _context.tb_LoaiPhim.Add(loaiPhimModel); await _context.SaveChangesAsync(); return(CreatedAtAction("GetLoaiPhimModel", new { id = loaiPhimModel.Id }, loaiPhimModel)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,TenLoai")] LoaiPhimModel loaiPhimModel) { if (id != loaiPhimModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(loaiPhimModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LoaiPhimModelExists(loaiPhimModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(loaiPhimModel)); }
public async Task <IActionResult> PutLoaiPhimModel(int id, LoaiPhimModel loaiPhimModel) { if (id != loaiPhimModel.Id) { return(BadRequest()); } _context.Entry(loaiPhimModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LoaiPhimModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <bool> Edit(int id, [Bind("Id,TenLoai,TrangThai")] LoaiPhimModel loaiPhimModel) { if (id != loaiPhimModel.Id) { return(false); } if (ModelState.IsValid) { try { _context.Update(loaiPhimModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LoaiPhimModelExists(loaiPhimModel.Id)) { return(false); } else { throw; } } return(true); } return(false); }
public async Task<IActionResult> Create([Bind("Id,TenLoai")] LoaiPhimModel loaiPhimModel) { if (ModelState.IsValid) { _context.Add(loaiPhimModel); await _context.SaveChangesAsync(); return RedirectToAction(nameof(Index)); } return View(loaiPhimModel); }
public async Task <bool> Create([Bind("Id,TenLoai,TrangThai")] LoaiPhimModel loaiPhimModel) { if (ModelState.IsValid) { loaiPhimModel.TrangThai = true; _context.Add(loaiPhimModel); await _context.SaveChangesAsync(); return(true); } return(false); }
// GET: Admin/LoaiPhim public async Task <IActionResult> Index(int?id, string?str) { LoaiPhimModel loaiPhimModel = null; if (id != null) { loaiPhimModel = await _context.tb_LoaiPhim.FirstOrDefaultAsync(m => m.Id == id); } if (str != null) { ViewBag.ListLoaiPhim = (from m in _context.tb_LoaiPhim where m.TenLoai.IndexOf(str) >= 0 select m).ToList(); } return(View(loaiPhimModel)); }