示例#1
0
 public ActionResult Edit([Bind(Include = "ID,Text,Link,Target,Status")] Menu menu)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var dao = new MenuDao();
             menu.Text   = menu.Text;
             menu.Link   = menu.Link;
             menu.Target = menu.Target;
             menu.Status = Convert.ToBoolean(true);
             var result = dao.Update(menu);
             if (result)
             {
                 SetAlert("Sửa thành công", "success");
                 ViewBag.Success = "Cập nhật thành công";
                 menu            = new Menu();
                 return(RedirectToAction("Index", "Menu"));
             }
             else
             {
                 ModelState.AddModelError("", "Cập nhật ko thành công");
             }
         }
     }
     catch (DbEntityValidationException e)
     {
         throw e;
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(View(menu));
 }
示例#2
0
 public bool Update([FromBody] Menu model)
 {
     try
     {
         return(_menuDao.Update(model));
     }
     catch (Exception ex)
     {
         nlog.Error(ex, "更新菜单失败!", model.ToJSON());
         return(false);
     }
 }
 public ActionResult Edit(tb_Menus entity)
 {
     if (ModelState.IsValid)
     {
         entity.Order  = entity.Order ?? 0;
         entity.Status = entity.Status ?? true;
         Dao.Update(entity);
     }
     ViewBag.TypeId   = new SelectList(Dao.ListAllType(), "Id", "Name", entity.TypeId);
     ViewBag.ParentId = new SelectList(Dao.ListAll(), "Id", "Text", entity.ParentId);
     return(View(entity));
 }
示例#4
0
        public void Update()
        {
            const int    id    = 1;
            const string name  = "首页";
            var          model = MenuDao.Get(id);

            model.Name = name;

            var result = MenuDao.Update(model);

            Assert.AreEqual(1, result);
        }
示例#5
0
        public void Update(int tenantId, MenuInfo info)
        {
            ArgumentHelper.AssertIsTrue(info != null, "MenuInfo is null");
            ArgumentHelper.AssertNotNullOrEmpty(info.MenuId, "MenuInfo.MenuId is null or empty");
            ArgumentHelper.AssertNotNullOrEmpty(info.Name, "MenuInfo.Name is null or empty");
            ArgumentHelper.AssertIsTrue(info.TenantId > 0, "MenuInfo.TenantId is 0");
            ArgumentHelper.AssertNotNullOrEmpty(info.AppAccountId, "MenuInfo.AppAccountId is null or empty");
            ArgumentHelper.AssertIsTrue(info.BeisenAppId > 0, "MenuInfo.BeisenAppId is 0");
            ArgumentHelper.AssertNotNullOrEmpty(info.Url, "MenuInfo.Url is null or empty");

            MenuDao.Update(info);
        }
示例#6
0
        public void Submit_OnClick(object sender, EventArgs e)
        {
            _menuInfo.ParentId     = _parentId;
            _menuInfo.Title        = TbTitle.Text;
            _menuInfo.Url          = TbUrl.Text;
            _menuInfo.IsOpenWindow = Convert.ToBoolean(DdlIsOpenWindow.SelectedValue);
            if (_menuId == 0)
            {
                _menuInfo.Id = MenuDao.Insert(_menuInfo);
            }
            else
            {
                MenuDao.Update(_menuInfo);
            }

            Response.Redirect(PageMenu.GetRedirectUrl());
        }
示例#7
0
 public ActionResult Edit(menu Menu)
 {
     if (ModelState.IsValid)
     {
         var  dao    = new MenuDao();
         bool result = dao.Update(Menu);
         if (result)
         {
             return(RedirectToAction("Index", "Menu"));
         }
         else
         {
             ModelState.AddModelError("", "Cập nhật menu thất bại");
         }
     }
     return(View("Index", "Menu"));
 }
示例#8
0
        public ActionResult Edit(Menu model)
        {
            if (ModelState.IsValid)
            {
                var dao = new MenuDao();

                var result = dao.Update(model);
                if (result)
                {
                    SetAlert("Update content thành công", "success");
                    return(RedirectToAction("Index", "Menu"));
                }
                else
                {
                    ModelState.AddModelError("", "Cập nhật content không thành công");
                }
            }
            return(View());
        }
示例#9
0
        public ActionResult Edit(Menu model)
        {
            try
            {
                // TODO: Add update logic here
                if (ModelState.IsValid)
                {
                    var dao    = new MenuDao();
                    var result = dao.Update(model);
                    return(RedirectToAction("Index"));
                }


                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
示例#10
0
        public ActionResult Edit(Menu model)
        {
            if (ModelState.IsValid)
            {
                var dao = new MenuDao();

                if (!string.IsNullOrEmpty(model.Text))
                {
                    var result = dao.Update(model);
                    if (result)
                    {
                        return(RedirectToAction("Index", "Menu"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Cap nhap thanh cong");
                    }
                }
            }
            return(View());
        }
示例#11
0
        public ActionResult Edit(Menu collection)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    // TODO: Add insert logic here

                    MenuDao   bdDao = new MenuDao();
                    UserLogin us    = (UserLogin)Session[SystemConsts.USER_SESSION];

                    collection.UpdatedBy   = us.UserName;
                    collection.UpdatedDate = Hepper.GetDateServer();
                    MenuDao     dbMenu     = new MenuDao();
                    MenuTypeDao dbMenuType = new MenuTypeDao();
                    var         items      = GetClientMenuViewModel();
                    ViewBag.ParentID = new SelectList(items, "ID", "Text");
                    ViewBag.GroupID  = new SelectList(dbMenuType.ToList(), "ID", "Name");
                    if (bdDao.Update(collection))
                    {
                        SetAlert("Thêm thành công", "success");
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        SetAlert("Không cập nhật được", "danger");
                    }
                }
                return(View());
            }
            catch
            {
                SetAlert("Không thêm được", "danger");
                return(View());
            }
        }