コード例 #1
0
        public ActionResult Catagory(long id, int page = 1, int pageSize = 1)
        {
            var catagory = new ProductCatagoryDAO().GetProductCatagoryByID(id);

            ViewBag.Catagory = catagory;

            int totalRecord = 0;
            var model       = new ProductDAO().GetProductByCatagoryID(id, ref totalRecord, page, pageSize);

            ViewBag.TotalRecord = totalRecord;
            ViewBag.Page        = page;

            int maxPage = 5;
            int totalPage;

            if (totalRecord < pageSize / 2)
            {
                totalPage = 1;
            }
            else
            {
                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));
        }
コード例 #2
0
        public void SetViewBag(long?selectedID = null)
        {
            var dao = new ProductCatagoryDAO();

            ViewBag.CatalogyID  = new SelectList(dao.GetCatagories(), "ID", "Name", selectedID);
            ViewBag.CatagoyList = dao.GetCatagories();
        }
コード例 #3
0
        public ActionResult Edit(long id)
        {
            SetViewBag();
            var dao     = new ProductCatagoryDAO();
            var product = dao.GetProductCatagoryByID(id);

            return(View(product));
        }
コード例 #4
0
        public JsonResult ChangeProductCatagoryStatus(long?productID)
        {
            var result = new ProductCatagoryDAO().ChangeProductCatagoryStatus(productID);

            return(Json(new
            {
                status = result
            }));
        }
コード例 #5
0
        // GET: Admin/ProductCatagory
        public ActionResult Index(string searchString, int page = 1, int pageSize = 10)
        {
            SetViewBag();
            var dao   = new ProductCatagoryDAO();
            var model = dao.ListAllPagingProductCatagory(searchString, page, pageSize);

            ViewBag.searchString = searchString;
            return(View(model));
        }
コード例 #6
0
        public ActionResult Edit(ProductCatagory product)
        {
            SetViewBag();
            var dao         = new ProductCatagoryDAO();
            var UserSession = (UserSession)Session[CommondConstant.USER_SESSION];

            product.ModifiedBy   = UserSession.Username;
            product.ModifiedDate = DateTime.Now;
            if (dao.UpdateProductCatagory(product))
            {
                SetAlert("Edit the product catagory sucessfull!", "success");
                return(RedirectToAction("Index", "ProductCatagory"));
            }

            else
            {
                ModelState.AddModelError("", "An error when edit product catagory!");
            }
            return(View());
        }
コード例 #7
0
        public ActionResult Create(ProductCatagory product)
        {
            SetViewBag();
            if (ModelState.IsValid)
            {
                var dao         = new ProductCatagoryDAO();
                var UserSession = (UserSession)Session[CommondConstant.USER_SESSION];
                product.CreatedBy = UserSession.Username;

                if (dao.InsertProductCatagory(product))
                {
                    SetAlert("Add the new product sucessfully!", "success");
                    return(RedirectToAction("Index", "ProductCatagory"));
                }
                else
                {
                    ModelState.AddModelError("", "An error when add the ProductCatagory!");
                }
            }

            return(View());
        }
コード例 #8
0
        public ActionResult ProductDetail(long id)
        {
            var productDAO     = new ProductDAO();
            var model          = productDAO.GetProductByID(id);
            var relatedProduct = productDAO.GetRelatedProductByCatagoryID(model.CatalogyID.Value, id);

            XElement xElement        = XElement.Parse(model.MoreImages);
            var      listStringImage = new List <string>();

            foreach (XElement item in xElement.Elements())
            {
                listStringImage.Add(item.Value);
            }
            ViewBag.ListMoreImage = listStringImage;
            var productCatagoryDAO = new ProductCatagoryDAO();
            var catagoryList       = productCatagoryDAO.GetAllCatagories();
            var catagory           = productCatagoryDAO.GetProductCatagoryByID(model.CatalogyID.Value);

            ViewBag.CatagoryList       = catagoryList;
            ViewBag.RelatedProductList = relatedProduct;
            ViewBag.Catagory           = catagory;

            return(View(model));
        }
コード例 #9
0
        public PartialViewResult _ProductCatagories()
        {
            var model = new ProductCatagoryDAO().GetAllCatagories();

            return(PartialView(model));
        }