partial void UpdatePicture(Picture instance);
partial void DeletePicture(Picture instance);
partial void InsertPicture(Picture instance);
private void detach_Picture(Picture entity) { this.SendPropertyChanging(); entity.PictureGroup = null; }
private void attach_Picture(Picture entity) { this.SendPropertyChanging(); entity.PictureGroup = this; }
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 }); }
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"); }