public async Task <IActionResult> PutTheloai(string id, Theloai theloai) { if (id != theloai.Matheloai) { return(BadRequest()); } _context.Entry(theloai).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TheloaiExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult DeleteConfirmed(string id) { Theloai theloai = db.Theloais.Find(id); db.Theloais.Remove(theloai); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Matheloai,Tentheloai,Ghichu")] Theloai theloai) { if (ModelState.IsValid) { db.Entry(theloai).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(theloai)); }
public ActionResult Create([Bind(Include = "Matheloai,Tentheloai,Ghichu")] Theloai theloai) { if (ModelState.IsValid) { db.Theloais.Add(theloai); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(theloai)); }
// GET: Theloais/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Theloai theloai = db.Theloais.Find(id); if (theloai == null) { return(HttpNotFound()); } return(View(theloai)); }
// GET: Theloais/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Theloai theloai = db.theloais.Find(id); List <SanPham> sanPhams = db.sanPhams.Where(x => x.MaLoai == id).ToList(); if (theloai == null) { return(HttpNotFound()); } return(View(sanPhams)); }
public async Task <ActionResult <Theloai> > PostTheloai(Theloai theloai) { _context.Theloai.Add(theloai); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (TheloaiExists(theloai.Matheloai)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetTheloai", new { id = theloai.Matheloai }, theloai)); }