コード例 #1
0
        public ActionResult Menu(string TypeMenu)
        {
            if (Session["isLoginAdmin"] != null && bool.Parse(Session["isLoginAdmin"].ToString()) == true)
            {
                switch (TypeMenu)
                {
                case "User":
                    ViewBag.DataList = UserAPIController.GetAllUser();
                    break;

                case "Category":
                    ViewBag.DataList = CategoryAPIController.getAllCategoryAdmin();
                    break;

                case "Product":
                    ViewBag.DataList = ProductAPIController.GetAllProduct();
                    break;
                }
                ViewBag.Type = TypeMenu;
                ViewBag.Size = ViewBag.DataList.Count;
                return(View());
            }
            else
            {
                return(Redirect("/Admin/Login"));
            }
        }
コード例 #2
0
 public ActionResult ProductAdmin(int productID)
 {
     if (productID == 0)
     {
         ViewBag.Product = new Product();
     }
     else
     {
         ViewBag.Product = ProductAPIController.GetProductByID(productID);
     }
     ViewBag.ImageURL     = "~/images/" + ViewBag.Product.ImageName;
     ViewBag.CategoryList = CategoryAPIController.getAllCategoryAdmin();
     return(View());
 }
コード例 #3
0
 public ActionResult CategoryAdmin(int categoryID)
 {
     if (categoryID == 0)
     {
         List <Category> data = new List <Category>();
         data.Add(new Category());
         ViewBag.Category = data;
     }
     else
     {
         ViewBag.Category = CategoryAPIController.getCategory(categoryID, "");
     }
     return(View());
 }
コード例 #4
0
        public ActionResult ProductAdmin(int productID, string productName, string description, int price, int categoryid, HttpPostedFileBase ImageURL)
        {
            if (ImageURL != null && ImageURL.ContentLength > 0)
            {
                // create file name mapping with product name
                var fileName = Path.GetFileName(ImageURL.FileName);
                // store the file inside ~/App_Data/uploads folder
                var path = Path.Combine(Server.MapPath("~/images"), fileName);
                checkFileExist(path);
                ImageURL.SaveAs(path);
            }
            ViewBag.Product = new Product()
            {
                ProductID   = productID,
                ProductName = productName,
                Description = description,
                Price       = price,
                CategoryID  = categoryid,
                ImageName   = Path.GetFileName(ImageURL.FileName)
            };
            HttpResult result = ProductAPIController.ProductMerge(ViewBag.Product);

            if (result.Result)
            {
                ViewBag.Success = true;
            }
            else
            {
                ViewBag.Error = result.Message;
            }
            ViewBag.CategoryList = CategoryAPIController.getAllCategoryAdmin();
            foreach (Category c in ViewBag.CategoryList)
            {
                if (c.CategoryID == ViewBag.Product.CategoryID)
                {
                    ViewBag.Product.CategoryName = c.CategoryName;
                }
            }
            return(View());
        }
コード例 #5
0
        public ActionResult CategoryAdmin(int categoryID, string categoryName)
        {
            Category category = new Category()
            {
                CategoryID   = categoryID,
                CategoryName = categoryName
            };
            HttpResult result = CategoryAPIController.CategoryMerge(category);

            if (result.Result)
            {
                ViewBag.Success = true;
            }
            else
            {
                ViewBag.Error = result.Message;
            }
            List <Category> data = new List <Category>();

            data.Add(category);
            ViewBag.Category = data;
            return(View());
        }