// GET: Category public ActionResult Index() { CategoryDao catDao = new CategoryDao(); List <ProductCategory> lst = catDao.GetAllCategory(); return(View(lst)); }
public void setViewBag(long?selectedID = null) { var categorydao = new CategoryDao(); //Viewbag để bingding dữ liệu từ model sang views //Chọn thằng nào có CategoryID ViewBag.CategoryID = new SelectList(categorydao.GetAllCategory(), "ID", "Name", selectedID); }
public ActionResult ListCategories() { string lang = null; HttpCookie langCookie = Request.Cookies["culture"]; if (langCookie != null) { lang = langCookie.Value; } ViewBag.Lang = lang; return(PartialView("_ListCategories", CategoryDao.GetAllCategory().ToList())); }
//Render page Create new book public ActionResult Create() { //get list categories existing and assign for viewbag SelectList categories = new SelectList(CategoryDao.GetAllCategory(), "categoryID", "categoryName"); ViewBag.Categories = categories; //get list authors existing and assign for viewbag SelectList authors = new SelectList(AuthorDao.GetListAuthors(), "authorID", "authorName"); ViewBag.Authors = authors; //get list publishers existing and assign for viewbag SelectList publishers = new SelectList(PublisherDao.GetListPublisher(), "publisherID", "publisherName"); ViewBag.Publishers = publishers; return(PartialView("_CreateBook", new Book())); }
//Render page edit book by book id public ActionResult Edit(int id) { //get book need to edit var book = BookDao.GetBook(id); //store older picture if user don't choose new picture oldPicture = book.Picture; //get list categories existing and assign for viewbag SelectList categories = new SelectList(CategoryDao.GetAllCategory(), "categoryID", "categoryName", book.Category.CategoryName); ViewBag.Categories = categories; //get list authors existing and assign for viewbag SelectList authors = new SelectList(AuthorDao.GetListAuthors(), "authorID", "authorName", book.Author.AuthorName); ViewBag.Authors = authors; //get list publishers existing and assign for viewbag SelectList publishers = new SelectList(PublisherDao.GetListPublisher(), "publisherID", "publisherName", book.Publisher.PublisherName); ViewBag.Publishers = publishers; return(View("_EditBook", book)); }
/// <summary> /// GetAllCategory - lấy về tất cả category /// </summary> /// <returns></returns> public DataTable GetAllCategory() { return(categoryDao.GetAllCategory()); }
public void SetViewBag(long?selectedID = null) { var categoryDao = new CategoryDao(); ViewBag.CategoryID = new SelectList(categoryDao.GetAllCategory(), "ID", "Name", selectedID); }