/// <summary>
 /// Create a new Comment object.
 /// </summary>
 /// <param name="commentID">Initial value of the CommentID property.</param>
 /// <param name="content">Initial value of the Content property.</param>
 /// <param name="movieID">Initial value of the MovieID property.</param>
 /// <param name="userID">Initial value of the UserID property.</param>
 public static Comment CreateComment(global::System.Int32 commentID, global::System.String content, global::System.Int32 movieID, global::System.Guid userID)
 {
     Comment comment = new Comment();
     comment.CommentID = commentID;
     comment.Content = content;
     comment.MovieID = movieID;
     comment.UserID = userID;
     return comment;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Comments EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToComments(Comment comment)
 {
     base.AddObject("Comments", comment);
 }
Пример #3
0
        //Method that updates comment
        public bool UpdateComment(UserCommentDTO UpdatedComment)
        {
            bool check = false;
            using (TransactionScope Trans = new TransactionScope())
            {
                try
                {
                    using (var context = new CinemaEntities())
                    {
                        var results = (from cm in context.Comments
                                       where cm.CommentID == UpdatedComment.commentID
                                       select cm);
                        if (results != null)
                        {
                            Comment CommentToUpdate = new Comment();
                            CommentToUpdate = (Comment)results.First();
                            CommentToUpdate.Content = UpdatedComment.Content;
                            context.ObjectStateManager.ChangeObjectState(CommentToUpdate, System.Data.EntityState.Modified);
                            context.SaveChanges();
                        }
                    }

                }
                catch
                {
                    check = false;
                    Trans.Dispose();
                    return check;
                }

                check = true;
                Trans.Complete();
                return check;
            }
        }