Exemplo n.º 1
0
        public ActionResult Add(Music.Model.EF.Category category, HttpPostedFileBase IMG, string del)
        {
            category.category_bin = false;

            if (category.category_active != true && category.category_active != false)
            {
                category.category_active = false;
            }

            //Chèn ảnh
            if (IMG != null)
            {
                var code = Guid.NewGuid().ToString();
                var img  = new FilesController();
                img.AddImages(IMG, Common.Link.IMG_CATEGORY, code);
                category.category_img = code + IMG.FileName;
            }
            else
            {
                category.category_img = "notImg.png";
            }

            if (categoriesDAO.ADD(category))
            {
                return(Redirect("/Admin/CategoryAdmin"));
            }
            else
            {
                return(Redirect(Common.Link.NOT_404));
            }
        }
Exemplo n.º 2
0
        public ActionResult Edit(Music.Model.EF.Category category, HttpPostedFileBase IMG, string del)
        {
            Category cate = db.Categories.Find(category.category_id);

            category.category_bin        = false;
            category.category_datecreate = cate.category_datecreate;
            category.category_view       = cate.category_view;
            category.user_id             = cate.user_id;

            if (category.category_active != true && category.category_active != false)
            {
                category.category_active = false;
            }

            //Chèn ảnh
            if (IMG != null)
            {
                var code = Guid.NewGuid().ToString();
                var img  = new FilesController();
                img.AddImages(IMG, Common.Link.IMG_CATEGORY, code);
                category.category_img = code + IMG.FileName;
            }
            else
            {
                category.category_img = cate.category_img;
            }

            if (categoriesDAO.Edit(category))
            {
                return(Redirect("/Admin/CategoryAdmin"));
            }
            else
            {
                return(Redirect(Common.Link.NOT_404));
            }
        }