public JsonResult ChangeStatus(long id) { var result = new CategoryD().ChangeStatus(id); return(Json(new { status = result })); }
// 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; }
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")); }
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")); }
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)); }
public void SetViewBag(long?selectedId = null) { var dao = new CategoryD(); ViewBag.CategoryID = new SelectList(dao.ListAll(), "ID", "Name", selectedId); }
public ActionResult Edit(int id) { var category = new CategoryD().ViewDetail(id); return(View(category)); }