Esempio n. 1
0
        public JsonResult DeleteMenu(string ids)
        {
            var msg   = new MsgBase();
            int count = 0;

            string[] arr = ids.Split(',');
            try {
                foreach (string id in arr)
                {
                    int i = mBll.Delete(int.Parse(id));
                    if (i > 0)
                    {
                        count++;
                    }
                }
                msg.Message = count > 0
                                        ? MsgBase.SuccessMessage + string.Format(",共删除{0}条信息", count)
                                        : MsgBase.FailMessage;
                msg.Code = count > 0 ? 1 : 0;
            }
            catch (Exception) {
                msg.Code    = -1;
                msg.Message = MsgBase.ErrMessage;
            }
            return(Json(msg));
        }
Esempio n. 2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DAL.Menu     menu = (DAL.Menu) this.tabControl.SelectedTab.Tag;
            DialogResult dr   = MessageBox.Show("Delete menu \"" + menu.Name + "\"", "Confirm", MessageBoxButtons.YesNo);

            if (dr == DialogResult.Yes)
            {
                MenuBLL menuBLL = new MenuBLL();
                menuBLL.Delete(menu);
                this.LoadData();
            }
        }
Esempio n. 3
0
        public ActionResult Delete(Guid id)
        {
            Menu      obj       = MenuBLL.GetById(id);
            UrlRecord urlRecord = UrlBLL.Table.FirstOrDefault(o => o.EntityName == "Menu" && o.EntityId == obj.Id);

            if (urlRecord != null)
            {
                UrlBLL.Delete(urlRecord);
            }
            MenuBLL.Delete(obj);
            CacheManager.Remove(Consts.MenuCacheKey);
            CacheManager.Remove(Consts.UrlRecordCacheKey);
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
        public void TestDeleteMenu(Menu menu)
        {
            bool isDelete = true;

            menuBLL.Delete(menu);
            List <Menu> menus = menuBLL.ListMenu();

            for (int i = 0; i < menus.Count; i++)
            {
                if (menus[i].ID == menu.ID)
                {
                    isDelete = false;
                }
            }
            Assert.AreEqual(isDelete, true);
        }
Esempio n. 5
0
        public JObject Delete(JObject josn)
        {
            var     id            = josn["ID"].Value <int>();
            MenuBLL menuBll       = new MenuBLL();
            var     deleteSuccess = menuBll.Delete(id);
            JObject result        = new JObject();

            if (deleteSuccess == 1)
            {
                result["success"] = true;
            }
            else
            {
                result["errorMsg"] = "删除失败!";
            }
            return(result);
        }
Esempio n. 6
0
        public void TestDeleteAllMenuItemAndMenu()
        {
            string      nameExpected = "Ăn rạng sáng";
            int         menuID       = 0;
            Menu        menu         = menuBLL.CreateMenu(nameExpected);
            List <Menu> menus        = menuBLL.ListMenu();

            for (int i = 0; i < menus.Count; i++)
            {
                if (menus[i].Name == nameExpected)
                {
                    menuID = menus[i].ID;
                }
            }

            int    menuIDTest     = menuID;
            string nameTest       = "Phá lấu bò gà heo";
            int    priceTest      = 30000;
            int    priceAfterTest = 25000;
            string rootPath       = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory).Parent.Parent.Parent.FullName;

            byte[] imageTest = File.ReadAllBytes(rootPath + "/data/images/com-chien-ca-man.jpg");

            int    menuIDTest1     = menuID;
            string nameTest1       = "Gà lá giang";
            int    priceTest1      = 39000;
            int    priceAfterTest1 = 25900;
            string rootPath1       = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory).Parent.Parent.Parent.FullName;

            byte[] imageTest1 = File.ReadAllBytes(rootPath + "/data/images/com-chien-ca-man.jpg");

            MenuItem menuItemTest = new MenuItem();

            menuItemTest.MenuID     = menuIDTest;
            menuItemTest.Name       = nameTest;
            menuItemTest.Price      = priceTest;
            menuItemTest.PriceAfter = priceAfterTest;
            menuItemTest.Image      = imageTest;

            MenuItem menuItemTest1 = new MenuItem();

            menuItemTest1.MenuID     = menuIDTest1;
            menuItemTest1.Name       = nameTest1;
            menuItemTest1.Price      = priceTest1;
            menuItemTest1.PriceAfter = priceAfterTest1;
            menuItemTest1.Image      = imageTest1;

            MenuItem menuItemExpected  = menuItemBLL.CreateMenuItem(menuItemTest);
            MenuItem menuItemExpected1 = menuItemBLL.CreateMenuItem(menuItemTest1);

            bool isDelete = true;

            menuBLL.Delete(menu);
            List <Menu> menus1 = menuBLL.ListMenu();

            for (int i = 0; i < menus1.Count; i++)
            {
                if (menus1[i].ID == menu.ID)
                {
                    isDelete = false;
                }
            }
            Assert.AreEqual(isDelete, true);
        }
Esempio n. 7
0
        public JsonResult Delete(int ID)
        {
            var result = bll.Delete(ID);

            return(Json(result));
        }