/// <summary> /// Fetches group event comments by specified arguments. /// It returns an empty array if there are no group event comments in DB by specified arguments. /// If these arguments are null it returns all group event comments from DB. /// </summary> /// <param name="id">The id.</param> /// <param name="groupEventID">The group event ID.</param> /// <param name="username">The username.</param> /// <param name="sortColumn">The sort column.</param> /// <returns></returns> private static GroupEventsComment[] Fetch(int? id, int? groupEventID, string username, eSortColumn sortColumn) { using (SqlConnection conn = Config.DB.Open()) { SqlDataReader reader = SqlHelper.ExecuteReader(conn, "FetchGroupEventsComments", id, groupEventID, username, sortColumn); List <GroupEventsComment> lGroupEventsComments = new List<GroupEventsComment>(); while(reader.Read()) { GroupEventsComment groupEventsComment = new GroupEventsComment(); groupEventsComment.id = (int) reader["ID"]; groupEventsComment.groupEventID = (int) reader["GroupEventID"]; groupEventsComment.username = (string) reader["Username"]; groupEventsComment.comment = (string) reader["Comment"]; groupEventsComment.date = (DateTime) reader["Date"]; lGroupEventsComments.Add(groupEventsComment); } return lGroupEventsComments.ToArray(); } }
protected void btnSubmitNewComment_Click(object sender, EventArgs e) { if (txtNewComment.Text.Trim() == "") { return; } if (CurrentUserSession != null) { var comment = new GroupEventsComment(EventID, CurrentUserSession.Username) { Comment = (Config.Misc.EnableBadWordsFilterGroups ? Parsers.ProcessBadWords(txtNewComment.Text.Trim()) : txtNewComment.Text.Trim()) }; comment.Save(); loadComments(); } }