예제 #1
0
 partial void UpdatePicture(Picture instance);
예제 #2
0
 partial void DeletePicture(Picture instance);
예제 #3
0
 partial void InsertPicture(Picture instance);
예제 #4
0
		private void detach_Picture(Picture entity)
		{
			this.SendPropertyChanging();
			entity.PictureGroup = null;
		}
예제 #5
0
		private void attach_Picture(Picture entity)
		{
			this.SendPropertyChanging();
			entity.PictureGroup = this;
		}
예제 #6
0
 public ActionResult Edit(Picture picture)
 {
     BizPicture.Update(pic => pic.PictureID == picture.PictureID,
         pic => new Picture { Description = picture.Description, OrderInGroup= picture.OrderInGroup }
     );
     return RedirectToAction("Index", "AdminPictureGroup", new { id = picture.GroupID });
 }
예제 #7
0
        public ActionResult UploadImage(int groupId)
        {
            if (Request.Files != null && Request.Files.Count > 0)
            {
                Picture picture = null;
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    HttpPostedFileBase imageFile = Request.Files[i];

                    if (imageFile.ContentLength <= 0)
                        continue;
                    picture = new Picture();
                    picture.GroupID = groupId;
                    picture.OrderInGroup = 0;
                    picture.AddTime = DateTime.Now;
                    BizPicture.AddPicture(picture);

                    try
                    {
                        string imageName = null;
                        string dir = StringUtility.GetSavePath(picture.PictureID, out imageName);

                        picture.LocalPath = dir + imageName + "_o" + Path.GetExtension(imageFile.FileName);
                        picture.ThumbnailPath = dir + imageName + "_t" + Path.GetExtension(imageFile.FileName);
                        BizPicture.Update(
                            picture.PictureID,
                            pic => new Picture
                            {
                                LocalPath = picture.LocalPath,
                                ThumbnailPath = picture.ThumbnailPath
                            }
                        );
                        string folder = Settings.Default.UploadFolder.Substring(1);
                        string str = string.Format("{0}{1}{2}", AppDomain.CurrentDomain.BaseDirectory, folder, dir);
                        Directory.CreateDirectory(str);
                        imageFile.SaveAs(string.Format("{0}{1}{2}", AppDomain.CurrentDomain.BaseDirectory, folder, picture.LocalPath));

                        ImagePlus imagePlus = new ImagePlus(imageFile.InputStream);
                        imagePlus.MakeThumbnail(160, 120,2);
                        imagePlus.SaveAs(string.Format("{0}{1}{2}", AppDomain.CurrentDomain.BaseDirectory, folder, picture.ThumbnailPath));
                    }
                    catch
                    {
                        BizPicture.Delete(picture.PictureID);
                        throw;
                    }
                }
            }
            return Content("1");
        }