示例#1
0
        public ActionResult Edit(Category category, HttpPostedFileBase IMG)
        {
            Category cate = db.Categories.Find(category.category_id);

            category.category_active     = cate.category_active;
            category.category_datecreate = cate.category_datecreate;
            category.category_dateupdate = DateTime.Now;
            category.category_bin        = cate.category_bin;
            category.category_option     = cate.category_option;
            category.category_view       = cate.category_view;
            category.user_id             = cate.user_id;

            var i = new ImagesController();

            if (IMG != null)
            {
                var code = Guid.NewGuid().ToString();
                var img  = new ImagesController();
                img.AddImages(IMG, Common.Link.IMG_CATEGORY, code);
                category.category_img = code + IMG.FileName;
            }
            else
            {
                category.category_img = cate.category_img;
            }


            var dao = new CategoriesDAO();

            if (dao.Edit(category))
            {
                return(Redirect("/Admin/CategoriesAdmin"));
            }
            else
            {
                return(Redirect(Common.Link.NOT_404));
            }
        }
示例#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));
            }
        }