示例#1
0
        public ActionResult Update(TopMenu entity)
        {
            bool result;

            if (ModelState.IsValid)
            {
                try
                {
                    result = new TopMenuDao().Update(entity);
                }
                catch (Exception ex)
                {
                    return(View("Error", new HandleErrorInfo(ex, "TopMenu", "Create")));
                }
                if (result)
                {
                    ModelState.AddModelError("", "Cập nhật thành công");
                    return(RedirectToAction("Index", "TopMenu"));
                }
                else
                {
                    ModelState.AddModelError("", "Cập nhật không thành công");
                    return(View());
                }
            }
            else
            {
                ModelState.AddModelError("", "Vui lòng nhập đầy đủ thông tin");
                return(View());
            }
        }
示例#2
0
        public ActionResult Create(TopMenu entity)
        {
            int id;

            if (ModelState.IsValid)
            {
                try
                {
                    entity.Status    = true;
                    entity.CreatedOn = DateTime.Now;
                    id = new TopMenuDao().Insert(entity);
                }
                catch (Exception ex)
                {
                    return(View("Error", new HandleErrorInfo(ex, "TopMenu", "Index")));
                }
                if (id > 0)
                {
                    ModelState.AddModelError("", "Thêm mới thành công");
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("", "Thêm mới không thành công");
                    return(View());
                }
            }
            else
            {
                ModelState.AddModelError("", "Vui lòng nhập đầy đủ thông tin");
                return(View());
            }
        }
示例#3
0
        public JsonResult ChangeStatus(int id)
        {
            var result = new TopMenuDao().ChangesStatus(id);

            return(Json(new
            {
                status = result
            }));
        }
示例#4
0
        public ActionResult Delete(int id)
        {
            bool result = new TopMenuDao().Delete(id);

            if (result)
            {
                ModelState.AddModelError("", "Xóa thành công");
                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("", "Xóa không thành công");
                return(RedirectToAction("Index"));
            }
        }
示例#5
0
        public ActionResult Update(int id)
        {
            var model = new TopMenuDao().GetById(id);

            return(View(model));
        }
示例#6
0
        // GET: TopMenu
        public ActionResult Index(int page = 1, int pageSize = 1)
        {
            var model = new TopMenuDao().ListAllPaging(page, pageSize);

            return(View(model));
        }