public void InsertComment(int id) { GalleryEntities context = new GalleryEntities(); Comment comment = new Comment(); comment.CreateTS = DateTime.Now; comment.Imgtext = txtComment.Text; comment.ImageSize = fplFileUpload.FileBytes.Length; comment.ImageID = id; context.Comment.Add(comment); context.SaveChanges(); }
public void InsertGallery(string UUIDName) { var context = new GalleryEntities (); Image image = new Image(); image.CreateTS = DateTime.Now; image.BaseName = fplFileUpload.FileName; image.UUIDName = UUIDName; image.FileSize = fplFileUpload.FileBytes.Length; image.Rating = -1; context.Image.Add(image); context.SaveChanges(); int id = image.ID; InsertComment(id); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string ID = Request.QueryString["ID"]; int CommentID = int.Parse(ID); GalleryEntities context = new GalleryEntities(); var comment = context.Comment.Where(Comment => Comment.ID == CommentID); foreach (Comment CommentData in comment) { txtComment.Text = CommentData.Imgtext; } } }
protected void btnEditComment_Click(object sender, EventArgs e) { lblMessage.Text = ""; string ID = Request.QueryString["ID"]; int commentID = int.Parse(ID); GalleryEntities context = new GalleryEntities(); var comment = new Comment(); comment.Imgtext = txtComment.Text; comment.ID = commentID; context.Comment.Attach(comment); var entry = context.Entry(comment); entry.Property(c => c.Imgtext).IsModified = true; entry.Property(c => c.ID).IsModified = false; context.SaveChanges(); lblMessage.Text = "Save changes"; }