Пример #1
0
        public JsonResult ChangeStatus(long id)
        {
            var result = new CategoryD().ChangeStatus(id);

            return(Json(new
            {
                status = result
            }));
        }
Пример #2
0
        // GET: Admin/Category

        public ActionResult Index(string searchString, int page = 1, int pageSize = 10)
        {
            var dao   = new CategoryD();
            var model = dao.ListAllPaging(searchString, page, pageSize);

            ViewBag.SearchString = searchString;

            return(View(model));
        }
        public CategoryController(NWContext context, IRepository <Category, int> cR, CategoryRepository cR2, CategoryD cD, IAuthorizationService authorizationService)
        {
            _context = context;
            _cR      = cR;
            _cR2     = cR2;

            _cD = cD;

            rs = new RequestSettings(this);

            _authorizationService = authorizationService;
        }
Пример #4
0
        public ActionResult Create(Category category)
        {
            if (ModelState.IsValid)
            {
                var  dao = new CategoryD();
                long id  = dao.Insert(category);
                if (id > 0)
                {
                    SetAlert("Thêm category thành công", "success");

                    return(RedirectToAction("Index", "Category"));
                }
                else
                {
                    ModelState.AddModelError("", "Thêm Category không thành công");
                }
            }
            return(View("Index"));
        }
Пример #5
0
        public ActionResult Edit(Category category)
        {
            if (ModelState.IsValid)
            {
                var dao = new CategoryD();

                var result = dao.Update(category);
                if (result)
                {
                    SetAlert("Cập Nhật category thành công", "success");

                    return(RedirectToAction("Index", "Category"));
                }
                else
                {
                    ModelState.AddModelError("", "Cập Nhật không thành công");
                }
            }
            return(View("Index"));
        }
Пример #6
0
        public ActionResult Category(long cateId, int page = 1, int pageSize = 1)
        {
            var category = new CategoryD().ViewDetail(cateId);

            ViewBag.Category = category;
            int totalRecord = 0;
            var model       = new ProductD().ListByCategoryId(cateId, ref totalRecord, page, pageSize);

            ViewBag.Total = totalRecord;
            ViewBag.Page  = page;
            int maxPage   = 5;
            int totalPage = 0;

            totalPage         = (int)Math.Ceiling((double)(totalRecord / pageSize));
            ViewBag.TotalPage = totalPage;
            ViewBag.MaxPage   = maxPage;
            ViewBag.First     = 1;
            ViewBag.Last      = totalPage;
            ViewBag.Next      = page + 1;
            ViewBag.Prev      = page - 1;
            return(View(model));
        }
Пример #7
0
        public void SetViewBag(long?selectedId = null)
        {
            var dao = new CategoryD();

            ViewBag.CategoryID = new SelectList(dao.ListAll(), "ID", "Name", selectedId);
        }
Пример #8
0
        public ActionResult Edit(int id)
        {
            var category = new CategoryD().ViewDetail(id);

            return(View(category));
        }