コード例 #1
0
        public ActionResult Edit(Author author, HttpPostedFileBase IMG)
        {
            Author au = db.Authors.Find(author.author_id);

            author.author_active     = au.author_active;
            author.author_datecreate = au.author_datecreate;
            author.author_dateupdate = DateTime.Now;
            author.author_bin        = au.author_bin;
            author.author_option     = au.author_option;
            author.user_id           = au.user_id;

            var i = new ImagesController();

            if (IMG != null)
            {
                var code = Guid.NewGuid().ToString();
                var img  = new ImagesController();
                img.AddImages(IMG, Common.Link.IMG_AUTHOR, code);
                author.author_img = code + IMG.FileName;
            }
            else
            {
                author.author_img = au.author_img;
            }


            var dao = new AuthorsDAO();

            if (dao.Edit(author))
            {
                return(Redirect("/Admin/authorsAdmin"));
            }
            else
            {
                return(Redirect(Common.Link.NOT_404));
            }
        }
コード例 #2
0
        public ActionResult Edit(Music.Model.EF.Author author, HttpPostedFileBase IMG, string del)
        {
            Author au = db.Authors.Find(author.author_id);

            author.author_bin        = false;
            author.author_datecreate = au.author_datecreate;
            author.author_dateupdate = DateTime.Now;
            author.author_active     = true;

            if (author.author_active != true && author.author_active != false)
            {
                author.author_active = false;
            }

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

            if (authorsDAO.Edit(author))
            {
                return(Redirect("/Admin/AuthorsAdmin"));
            }
            else
            {
                return(Redirect(Common.Link.NOT_404));
            }
        }