示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
           
            using (DataStorage context = new DataStorage())
            {

                string imageName = Request.Files["image"].FileName;
                if (!string.IsNullOrEmpty(imageName))
                {
                    imageName = Path.GetFileName(imageName);
                    string imagePath = Server.MapPath("~/Content/Objects/" + imageName);
                    Request.Files["image"].SaveAs(imagePath);
                    Request.Files["image"].InputStream.Close();
                    ImageContent imageItem = new ImageContent();
                    imageItem.FileName = imageName;
                    imageItem.Language = SystemSettings.CurrentLanguage;
                    imageItem.Url = Request.Form["url"];
                    context.AddToImageContent(imageItem);
                    context.SaveChanges();
                }

                
                
                //List<ImageContent> images = context.ImageContent.Where(i => i.Language == SystemSettings.CurrentLanguage).Select(i => i).ToList();
                //return View(images);
            }
            Response.Write("<script>window.close()</script>");
            //Response.Redirect("Admin/EditPicture/?contentUrl=" + contentUrl + "&controllerName=" + controllerName);
        }
示例#2
0
        public ActionResult EditPicture(FormCollection form)
        {
            using (DataStorage context = new DataStorage())
            {

                string imageName = Request.Files["image"].FileName;
                if (!string.IsNullOrEmpty(imageName))
                {
                    imageName = Path.GetFileName(imageName);
                    string imagePath = Server.MapPath("~/Content/Objects/" + imageName);
                    Request.Files["image"].SaveAs(imagePath);
                    Request.Files["image"].InputStream.Close();
                    ImageContent imageItem = new ImageContent();
                    imageItem.FileName = imageName;
                    imageItem.Language = SystemSettings.CurrentLanguage;
                    imageItem.Url = form["url"];
                    context.AddToImageContent(imageItem);
                    context.SaveChanges();
                }

                List<ImageContent> images = context.ImageContent.Where(i => i.Language == SystemSettings.CurrentLanguage).Select(i => i).ToList();
                return View(images);
            }
        }