Esempio n. 1
0
        public ActionResult Save([Bind("ImgKey,ImgName,Height,Width")] Pri_ArticleImage_Entity img_Entity, string NewImgSrc)
        {
            var entity = imgdal.GetPri_ArticleImage_Entity(img_Entity.ImgKey);

            if (entity == null)
            {
                return(Content("图片信息无效"));
            }
            //判断是否重新上传过新的文件
            if (!string.IsNullOrWhiteSpace(NewImgSrc))
            {
                string fullname    = Path.Combine(_pubComService._OctOceanConfig.FileRoot_Cache_Image, entity.ArticleKey, img_Entity.ImgName);
                string newfullname = Path.Combine(_pubComService._OctOceanConfig.FileRoot_Web_Image, entity.ArticleKey, img_Entity.ImgName);
                //直接复制
                System.IO.File.Copy(fullname, newfullname, true);

                //修改旧的图片实体的信息
                entity.ImgName = img_Entity.ImgName;
                entity.Src     = _pubComService._OctOceanConfig.UrlRoot_Web_Image + $"/{entity.ArticleKey}/{img_Entity.ImgName}";
            }



            entity.Height     = img_Entity.Height;
            entity.Width      = img_Entity.Width;
            entity.UpdateTime = DateTime.Now;
            imgdal.UpdatePri_ArticleImage(entity);



            // return Content("<script>alert('Hello World!');</script>", "application/x-javascript");
            //return RedirectToRoute("image_edit",new { ImageKey = entity.ImgKey });
            return(RedirectToAction("Edit", new { ImageKey = entity.ImgKey }));
        }
Esempio n. 2
0
        public ActionResult Edit(string ImageKey)
        {
            Pri_ArticleImage_Entity entity = imgdal.GetPri_ArticleImage_Entity(ImageKey);

            if (entity == null)
            {
                return(Content("图片信息无效"));
            }
            return(View(entity));
        }
Esempio n. 3
0
        public int UpdatePri_ArticleImage(Pri_ArticleImage_Entity entity)
        {
            string sql = "UPDATE Pri_ArticleImage SET ImgName=@ImgName,Src=@Src,Height=@Height,Width=@Width,UpdateTime=GETDATE() WHERE ImgKey=@ImgKey ";

            return(connection.Execute(sql, new { entity.ImgKey, entity.ImgName, entity.Src, entity.Height, entity.Width }));
        }
Esempio n. 4
0
        public int InsertPri_ArticleImage(Pri_ArticleImage_Entity entity)
        {
            string sql = "INSERT INTO Pri_ArticleImage(ImgKey,ArticleKey,ImgName,Src,Height,Width,UpdateTime)VALUES(@ImgKey,@ArticleKey,@ImgName,@Src,@Height,@Width,GETDATE())";

            return(connection.Execute(sql, new { entity.ImgKey, entity.ArticleKey, entity.ImgName, entity.Src, entity.Height, entity.Width }));
        }