public async Task <IActionResult> PutPhanPhim(string id, PhanPhim phanPhim) { if (id != phanPhim.MaPhim) { return(BadRequest()); } _context.Entry(phanPhim).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PhanPhimExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IHttpActionResult PostPhanPhim(PhanPhim phanPhim) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.PhanPhims.Add(phanPhim); try { db.SaveChanges(); } catch (DbUpdateException) { if (PhanPhimExists(phanPhim.MaPhim)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = phanPhim.MaPhim }, phanPhim)); }
public IHttpActionResult PutPhanPhim(string id, PhanPhim phanPhim) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != phanPhim.MaPhim) { return(BadRequest()); } db.Entry(phanPhim).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PhanPhimExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetPhanPhim(string id) { PhanPhim phanPhim = db.PhanPhims.Find(id); if (phanPhim == null) { return(NotFound()); } return(Ok(phanPhim)); }
public IHttpActionResult DeletePhanPhim(string id) { PhanPhim phanPhim = db.PhanPhims.Find(id); if (phanPhim == null) { return(NotFound()); } db.PhanPhims.Remove(phanPhim); db.SaveChanges(); return(Ok(phanPhim)); }
public async Task <ActionResult <PhanPhim> > PostPhanPhim(PhanPhim phanPhim) { _context.PhanPhims.Add(phanPhim); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (PhanPhimExists(phanPhim.MaPhim)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetPhanPhim", new { id = phanPhim.MaPhim }, phanPhim)); }