Exemplo n.º 1
0
        public ActionResult UpdateBookCategory(int id)
        {
            var dao   = new BookCategoryDAO();
            var model = dao.BookCategoryDetail(id);

            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult UpdateBookCategory(BookCategory model)
        {
            if (ModelState.IsValid)
            {
                var dao = new BookCategoryDAO();
                //Kiểm tra xem tên loại sách này đã có chưa
                var exist = dao.BookCategoryExistForUpdate(model.Name, model.ID);
                if (!exist)
                {
                    UserLogin userlogin = (UserLogin)Session["USER_SESSION"];
                    model.ModifiedBy = userlogin.UserName;
                    string metatitle = CastString.Cast(model.Name);
                    model.MetaTitle = metatitle;
                    bool result = dao.UpdateBookCategory(model);
                    if (result)
                    {
                        SetAltert("Update loại sách thành công", 0);
                        return(RedirectToAction("Index", "BookCategory"));
                    }
                    else
                    {
                        SetAltert("Chưa cập nhật được", 2);
                    }
                }
                else
                {
                    SetAltert("Tên loại sách này đã có", 2);
                }
            }
            else
            {
            }

            return(View(model));
        }
Exemplo n.º 3
0
        // GET: Admin/ProductCategory
        public ActionResult Index()
        {
            var dao = new BookCategoryDAO();
            var listbookCategory = dao.listBookCategory();

            return(View(listbookCategory));
        }
        public ActionResult MenuBookCategory()
        {
            var dao   = new BookCategoryDAO();
            var model = dao.listBookCategoryClient();

            return(PartialView(model));
        }
Exemplo n.º 5
0
        public JsonResult saveData(string categoryStr, HttpPostedFileBase file)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();

            BookCategory category = serializer.Deserialize <BookCategory>(categoryStr);

            bool status = false;

            if (file != null)
            {
                category.Image = imgHelper.saveImage(file);
            }

            if (category.ID == 0)
            {
                status = new BookCategoryDAO().insert(category);
            }
            else
            {
                status = new BookCategoryDAO().update(category);
            }

            setViewBagForCategory();

            return(Json(new
            {
                status = status
            }));
        }
Exemplo n.º 6
0
        // GET: Category
        public ActionResult Index(int?page)
        {
            setViewBagForCategory();
            string Alias  = Request.Url.Segments[2];
            int    pasize = 1;
            int    panum  = (page ?? 1);

            setViewBagForCategory();
            if (Alias == "new-book")
            {
                var model = new BookDAO().GetNewBook();
                var md    = "Mới Tháng " + DateTime.Now.Month.ToString();
                ViewBag.CTLG = md;
                DateTime a     = DateTime.Now;
                int      month = a.Month;
                return(View(db.Books.Where(x => x.Status == true && x.CreatedDate.Value.Month == month).OrderBy(x => x.Name).ToPagedList(panum, pasize)));
            }
            else
            {
                var model = new BookDAO().GetBookByAliasCategory(Alias);
                var md    = new BookCategoryDAO().Alias(Alias).SingleOrDefault();
                ViewBag.CTLG = md.Name;
                var ctlg = db.BookCategories.Where(x => x.Alias == Alias).FirstOrDefault();
                return(View(db.Books.Where(x => x.CategoryID == ctlg.ID && x.Status == true).OrderBy(x => x.Name).ToPagedList(panum, pasize)));
            }
        }
Exemplo n.º 7
0
        public JsonResult ChangeStatus(long id)
        {
            var result = new BookCategoryDAO().ChangeStatus(id);

            return(Json(new
            {
                status = result
            }));
        }
Exemplo n.º 8
0
        public JsonResult Delete(int id)
        {
            var result = new BookCategoryDAO().delete(id);

            return(Json(new
            {
                status = result
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 9
0
        public JsonResult getDetail(int id)
        {
            BookCategoryDAO b     = new BookCategoryDAO();
            var             model = b.getCategoryByID(id);

            return(Json(new
            {
                data = model,
                status = true
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 10
0
        public void setViewBagForBook(long?selectedCategoryID = null, long?selectedAuthorID = null, long?selectedPublisherID = null)
        {
            ViewBag.listImage = imgHelper.loadListImage();
            var categoryDAO  = new BookCategoryDAO();
            var authorDAO    = new AuthorDAO();
            var publisherDAO = new PublisherDAO();

            ViewBag.Category  = new SelectList(categoryDAO.getListCategory(), "ID", "Name");
            ViewBag.Authors   = new SelectList(authorDAO.getListAuthor(), "ID", "Name");
            ViewBag.Publisher = new SelectList(publisherDAO.getListPublisher(), "ID", "Name");
        }
Exemplo n.º 11
0
        public JsonResult loadData()
        {
            IEnumerable <CategoryViewModel> model = new BookCategoryDAO().getAllCategory();

            model = model.OrderBy(x => x.CatalogID);

            var totalRow = model.Count();

            return(Json(new
            {
                data = model,
                totalRow = totalRow,
                status = true
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 12
0
 public ActionResult CreateBookCategory(BookCategory model)
 {
     if (ModelState.IsValid)
     {
         //Kiểm tra xem tên loại sản phẩm đã có chư
         var  dao    = new BookCategoryDAO();
         bool exsits = dao.BookCategoryExist(model.Name);
         if (!exsits)
         {
             UserLogin userlogin = (UserLogin)Session["USER_SESSION"];
             model.CreatedBy   = userlogin.UserName;
             model.CreatedDate = DateTime.Now;
             string metatitle = CastString.Cast(model.Name);
             model.MetaTitle = metatitle;
             bool result = dao.CreateBookCategory(model);
             if (result)
             {
                 SetAltert("Tạo mới loại sách thành công", 0);
                 return(RedirectToAction("Index", "BookCategory"));
             }
             else
             {
                 SetAltert("Chưa tạo loại sách được", 2);
             }
         }
         else
         {
             //trường hợp tên đã có
             SetAltert("Tên loại sách này đã có", 2);
         }
     }
     else
     {
     }
     return(View(model));
 }
Exemplo n.º 13
0
        //Phương thức này để khởi tạo cho Dropdownlist CategoryID trong View CreateProduct
        public void SetViewBag(long?selectedID = null)
        {
            var dao = new BookCategoryDAO();

            ViewBag.CategoryID = new SelectList(dao.listBookCategoryClient(), "id", "Name", selectedID);
        }
Exemplo n.º 14
0
        public ActionResult BookCategory()
        {
            var model = new BookCategoryDAO().ListAll().ToList();

            return(PartialView(model));
        }