public ActionResult DeleteConfirmed(string id) { drinktype drinktype = db.drinktypes.Find(id); db.drinktypes.Remove(drinktype); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "code,nameof")] drinktype drinktype) { if (ModelState.IsValid) { db.Entry(drinktype).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(drinktype)); }
public ActionResult Create([Bind(Include = "code,nameof")] drinktype drinktype) { if (ModelState.IsValid) { db.drinktypes.Add(drinktype); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(drinktype)); }
// Xóa một đối tượng public bool Delete(string code) { drinktype dbEntry = mycoffee.drinktypes.Find(code); if (dbEntry == null) { return(false); } mycoffee.drinktypes.Remove(dbEntry); mycoffee.SaveChanges(); return(true); }
// GET: Admin/drinktypesAdmin/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } drinktype drinktype = db.drinktypes.Find(id); if (drinktype == null) { return(HttpNotFound()); } return(View(drinktype)); }
// Thêm một đối tượng public bool Insert(drinktype model) { drinktype dbEntry = mycoffee.drinktypes.Find(model.code); if (dbEntry != null) { return(false); } mycoffee.drinktypes.Add(model); mycoffee.SaveChanges(); return(true); }
// Sửa một đối tượng public bool Update(drinktype model) { drinktype dbEntry = mycoffee.drinktypes.Find(model.code); // LoaiBanDoc dbEntry = mycoffee.LoaiBanDocs. // Where(x => x.LoaiBanDoc1 = model.LoaiBanDoc1).FirstOrDefault(); if (dbEntry == null) { return(false); } dbEntry.nameof = model.nameof; // Sửa các trường khác cũng như vậy mycoffee.SaveChanges(); return(true); }
// Trả về một đối tượng khi biết Khóa public drinktype FindEntity(string code) { drinktype dbEntry = mycoffee.drinktypes.Find(code); return(dbEntry); }