Example #1
0
        public ActionResult DeleteConfirmed(string id)
        {
            drinktype drinktype = db.drinktypes.Find(id);

            db.drinktypes.Remove(drinktype);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #2
0
 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));
 }
Example #3
0
        public ActionResult Create([Bind(Include = "code,nameof")] drinktype drinktype)
        {
            if (ModelState.IsValid)
            {
                db.drinktypes.Add(drinktype);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(drinktype));
        }
Example #4
0
        // 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);
        }
Example #5
0
        // 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));
        }
Example #6
0
        // 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);
        }
Example #7
0
        // 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);
        }
Example #8
0
        // 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);
        }