public ActionResult DeleteConfirmed(int id) { NewTypeProduct newTypeProduct = db.NewTypeProducts.Find(id); db.NewTypeProducts.Remove(newTypeProduct); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "TypeProductId,Name,Description,CreateAt,UpdateAt,Status")] NewTypeProduct newTypeProduct) { if (ModelState.IsValid) { db.Entry(newTypeProduct).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(newTypeProduct)); }
public ActionResult Create([Bind(Include = "TypeProductId,Name,Description,CreateAt,UpdateAt,Status")] NewTypeProduct newTypeProduct) { if (ModelState.IsValid) { db.NewTypeProducts.Add(newTypeProduct); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(newTypeProduct)); }
// GET: Admin/QLNewTypeProducts/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } NewTypeProduct newTypeProduct = db.NewTypeProducts.Find(id); if (newTypeProduct == null) { return(HttpNotFound()); } return(View(newTypeProduct)); }
//Sách theo chủ đề public ActionResult BanhTheoType(int?page, int Id) { //Kiem tra chu de ton tai hay k NewTypeProduct t = db.NewTypeProducts.SingleOrDefault(n => n.TypeProductId == Id); if (t == null) { Response.StatusCode = 404; return(null); } else { int pageSize = 2; int pageNumber = (page ?? 1); var listProduct = db.Products.Where(n => n.TypeProductId == Id).OrderByDescending(n => n.Prince); if (listProduct == null) { ViewBag.Cake = "Không Có Sách Nào Thuộc Chủ Đề Này"; } return(View(listProduct.ToPagedList(pageNumber, pageSize))); } }