protected void btnDelete_Click(object sender, EventArgs e) { TreeViewUpdateArgs tua = new TreeViewUpdateArgs(); tua.ChildContent = txtCommentContent.Text; int commentID; bool checkIntCommentID = int.TryParse(lblCommentID.Text, out commentID); tua.ChildID = commentID; tua.ActionToPerform = "Delete"; tua.UserName = System.Web.HttpContext.Current.User.Identity.Name; if (checkIntCommentID) { if (txtMovieTitle.Text.Length > 0) { if (TreeViewUpdateDelete != null) { TreeViewUpdateDelete(tua); } } } if (Model.IsValidTransastion == true) { txtMovieTitle.Text = ""; txtCommentContent.Text = ""; PopulateTreeView(); trvComments.CollapseAll(); lblStatus.Text = "Comment was deleted."; lblStatus.BackColor = Color.LightGreen; } }
protected void btnDelete_Click(object sender, EventArgs e) { TreeViewUpdateArgs tua = new TreeViewUpdateArgs(); tua.ChildContent = txtCommentContent.Text; int commentID; bool checkIntCommentID = int.TryParse(lblCommentID.Text, out commentID); tua.ChildID = commentID; tua.ActionToPerform = "Delete"; tua.UserName = System.Web.HttpContext.Current.User.Identity.Name; if (checkIntCommentID) { if (TreeViewUpdateDelete != null) { TreeViewUpdateDelete(tua); } } if (Model.IsValidTransastion == true) { txtMovieTitle.Text = ""; txtCommentContent.Text = ""; PopulateTreeView(); trvComments.CollapseAll(); lblStatus.Text = "Comment was deleted."; lblStatus.BackColor = Color.LightGreen; } }
private void UpdateDleteComment(TreeViewUpdateArgs tua) { IUser UserServices = new UserServices(); bool check = false; if (tua.ActionToPerform == "Delete") { int commentID = tua.ChildID; check = UserServices.DeleteComment(commentID); } else if (tua.ActionToPerform == "Update") { UserCommentDTO CommentToUpdate = new UserCommentDTO(); CommentToUpdate.commentID = tua.ChildID; CommentToUpdate.Content = tua.ChildContent; check = UserServices.UpdateComment(CommentToUpdate); } if (check) { Guid UserID = UserServices.GetUserID(tua.UserName); IList <UserCommentDTO> ListOfComments = UserServices.GetAllUserComments(UserID); IList <String> ListOfMovies = UserServices.GetMoviesToWhichTheUserCommented(UserID); Myview.Model.IsValidTransastion = true; Myview.Model.ListOfComments = new List <CommentLine>(); Myview.Model.ListOfMovies = new List <String>(); foreach (var item in ListOfComments) { //creating list of comments CommentLine row = new CommentLine(); row.CommentID = item.commentID; row.MovieTitle = item.MovieTitle; row.CommentContent = item.Content; row.MovieID = item.movieID; Myview.Model.ListOfComments.Add(row); } foreach (var item in ListOfMovies) { String row1 = null; row1 = item; bool checkIfContains = Myview.Model.ListOfMovies.Contains(row1); if (!checkIfContains) { Myview.Model.ListOfMovies.Add(row1); } } } }
private void UpdateDleteComment(TreeViewUpdateArgs tua) { IUser UserServices = new UserServices(); bool check = false; if (tua.ActionToPerform == "Delete") { int commentID = tua.ChildID; check = UserServices.DeleteComment(commentID); } else if (tua.ActionToPerform == "Update") { UserCommentDTO CommentToUpdate = new UserCommentDTO(); CommentToUpdate.commentID = tua.ChildID; CommentToUpdate.Content = tua.ChildContent; check = UserServices.UpdateComment(CommentToUpdate); } if (check) { Guid UserID = UserServices.GetUserID(tua.UserName); IList<UserCommentDTO> ListOfComments = UserServices.GetAllUserComments(UserID); IList<String> ListOfMovies = UserServices.GetMoviesToWhichTheUserCommented(UserID); Myview.Model.IsValidTransastion = true; Myview.Model.ListOfComments = new List<CommentLine>(); Myview.Model.ListOfMovies = new List<String>(); foreach (var item in ListOfComments) { //creating list of comments CommentLine row = new CommentLine(); row.CommentID = item.commentID; row.MovieTitle = item.MovieTitle; row.CommentContent = item.Content; row.MovieID = item.movieID; Myview.Model.ListOfComments.Add(row); } foreach (var item in ListOfMovies) { String row1 = null; row1 = item; bool checkIfContains = Myview.Model.ListOfMovies.Contains(row1); if (!checkIfContains) { Myview.Model.ListOfMovies.Add(row1); } } } }