public ActionResult SaveContact([FromBody] CommentEntity objComment) { APIResponse objResponse = new APIResponse(); try { if (ModelState.IsValid) { DBResponse obj = new DBResponse(); CommentDetails objCommentDetails = new CommentDetails(); obj = objCommentDetails.SaveComment(objComment); obj.Result = obj.ID > 0; objResponse.StatusMessage = obj.Result ? "Thanks for reply." : AppMessage.SystemError; objResponse.StatusCode = obj.Result ? APIStatusCode.Success.ToString() : APIStatusCode.InternalError.ToString();; } else { objResponse.StatusCode = APIStatusCode.ValidationFailed.ToString(); objResponse.StatusMessage = "Please fill in all required fields"; } } catch (Exception ex) { objResponse.StatusMessage = ex.Message; objResponse.StatusCode = APIStatusCode.SystemError; } return(Ok(objResponse)); }
public ActionResult TesterAddBug(DataView m)//(string BugTitle, string Priority, DateTime RaisedDate, string Comments) { try { //To fetch the data to database DatabaseClass ctx = new DatabaseClass(); BugPoolDetails r = new BugPoolDetails(); CommentDetails c = new CommentDetails(); r.BugTitle = m.BugTitle; r.Priority = m.Priority; r.RaisedDate = DateTime.Now; r.Status = "OPEN"; r.TesterId = int.Parse(Session["UserId"].ToString()); r.ProjectId = int.Parse(Session["ProjId"].ToString()); c.Comments = m.Comments; c.CommentDate = DateTime.Now; c.CommentedBy = int.Parse(Session["UserId"].ToString()); c.Bug = r; //Navigation Prop ctx.BugPoolDetail.Add(r); ctx.CommentDetail.Add(c); ctx.SaveChanges(); return(RedirectToAction("Tester", "Main")); } catch { return(RedirectToAction("Error", "Main")); } }
public ActionResult DeveloperResolve(DataView1 m) { try { if (ModelState.IsValid) { DatabaseClass ctx = new DatabaseClass(); CommentDetails c = new CommentDetails(); int bid = int.Parse(Session["BugId"].ToString()); var res = (from i in ctx.BugPoolDetail where i.BugId == bid select i).FirstOrDefault(); res.Status = "RESOLVED"; int uid = int.Parse(Session["UserId"].ToString()); c.CommentedBy = uid; c.Comments = m.dc; c.BugId = bid; c.CommentDate = DateTime.Now; ctx.CommentDetail.Add(c); ctx.SaveChanges(); return(RedirectToAction("Developer", "Main")); } return(View(m)); } catch { return(RedirectToAction("Error", "Main")); } }
protected void Page_Load(object sender, EventArgs e) { CommentId = Int64.Parse(Request.Params.Get("commentId")); IUnityContainer container = (IUnityContainer)HttpContext.Current.Application["unityContainer"]; ICommentService commentService = container.Resolve <ICommentService>(); ILinkService linkService = container.Resolve <ILinkService>(); CommentDetails comment = commentService.GetComment(CommentId); LinkId = comment.LinkId; LinkDetails link = linkService.GetLink(LinkId); lnkLink.NavigateUrl = Response.ApplyAppPathModifier("/Pages/Link/Link.aspx?linkId=" + LinkId); if (!IsPostBack) { txtText.Text = comment.Text; lblLink.Text = link.Name; lblMovie.Text = ApplicationManager.GetMovieTitle(link.MovieId); if (CookiesManager.GetPreferredSearchEngine(Context) == "webshop") { lnkMovie.NavigateUrl = Response.ApplyAppPathModifier("/Pages/Movie/Movie.aspx?movieId=" + link.MovieId); } else { lnkMovie.NavigateUrl = Response.ApplyAppPathModifier("/Pages/Movie/MovieXml.aspx?movieId=" + link.MovieId); } } }
/// <summary> /// Gets all the comments for the specified Community. /// </summary> /// <param name="filter">Filter which comments to be fetched</param> /// <param name="pageDetails">Details about the pagination</param> /// <returns>List of all comments of the Community</returns> public async Task <IEnumerable <CommentDetails> > GetCommunityComments(CommentFilter filter, PageDetails pageDetails) { this.CheckNotNull(() => new { filter, pageDetails }); Func <CommunityComments, object> orderBy = (communityComments) => communityComments.CommentedDatetime; Expression <Func <CommunityComments, bool> > condition = (communityComments) => communityComments.CommunityID == filter.EntityId && communityComments.IsDeleted == false; // Gets the total items satisfying the var totalItemsForCondition = _communityCommentRepository.GetItemsCount(condition); pageDetails.TotalPages = (totalItemsForCondition / pageDetails.ItemsPerPage) + ((totalItemsForCondition % pageDetails.ItemsPerPage == 0) ? 0 : 1); IEnumerable <CommunityComments> comments = _communityCommentRepository .GetItems(condition, orderBy, filter.OrderType == OrderType.NewestFirst, (pageDetails.CurrentPage - 1) * pageDetails.ItemsPerPage, pageDetails.ItemsPerPage); var commentDetails = new List <CommentDetails>(); if (comments != null) { foreach (var item in comments) { var comment = new CommentDetails(); Mapper.Map(item, comment); commentDetails.Add(comment); } } return(commentDetails); }
public IHttpActionResult SendComment(CommentDetails cmtDl) { logger.Info("Inside Report/SendComment"); ActionStatus status = new ActionStatus(); //int result = 0; try { reportService.SendComment(cmtDl, permission); } catch (BaseException ex) { status.Number = (int)ex.ErrorCode; } catch (Exception ex) { status.Number = -1; status.Message = "Comment not Sent"; logger.Info("Comment not Sent."); logger.Error("Exception in Report/SendComment: {0} \r\n {1}", ex.ToString(), ex.StackTrace); } if (status.Number != -1) { return(Ok(new { Status = status })); } else { return(InternalServerError()); } }
protected void Page_Load(object sender, EventArgs e) { long commentId = Int64.Parse(Request.Params.Get("commentId")); IUnityContainer container = (IUnityContainer)HttpContext.Current.Application["unityContainer"]; ICommentService commentService = container.Resolve <ICommentService>(); ILinkService linkService = container.Resolve <ILinkService>(); CommentDetails comment = commentService.GetComment(commentId); LinkDetails link = linkService.GetLink(comment.LinkId); lblLink.Text = link.Name; lnkLink.NavigateUrl = Response.ApplyAppPathModifier("~/Pages/Link/Link.aspx?linkId=" + link.LinkId); lblAuthor.Text = comment.AuthorName; lnkAuthor.NavigateUrl = Response.ApplyAppPathModifier("~/Pages/Comment/ListComments.aspx?userId=" + comment.AuthorId); lblDate.Text = comment.Date.ToString(); lblText.Text = comment.Text; if (SessionManager.IsUserAuthenticated(Context)) { long userId = SessionManager.GetUserSession(Context).UserProfileId; if ((userId == comment.AuthorId) || (userId == link.UserId)) { pControl.Visible = true; lnkEditComment.NavigateUrl = Response.ApplyAppPathModifier("~/Pages/Comment/EditComment.aspx?commentId=" + commentId); lnkEditComment.Visible = (userId == comment.AuthorId); lnkRemoveComment.NavigateUrl = Response.ApplyAppPathModifier("~/Pages/Comment/RemoveComment.aspx?commentId=" + commentId); } } }
public async Task <IActionResult> PostComment(CommentRequest model) { try { if (String.IsNullOrWhiteSpace(model.ArticleId) || String.IsNullOrWhiteSpace(model.CommentText) || String.IsNullOrWhiteSpace(model.ParentId)) { return(BadRequest(new { message = "Incomplete comment information" })); } var insertedComment = await databaseService.SaveCommentAsync(new Comment(model, currentUserId)); var commentDetails = new CommentDetails() { Id = insertedComment.Id, ArticleId = insertedComment.ArticleId, ChildrenCommentsCount = 0, CommentText = insertedComment.CommentText, ParentId = insertedComment.ParentId, UpdatedOn = insertedComment.UpdatedOn, User = await databaseService.GetUserAsync(insertedComment.UserId), Ranking = new CommentRankingDetails() }; return(Ok(commentDetails)); } catch (Exception ex) { logger.LogError(ex, ex.Message); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
/// <summary> /// Updates an existing comment /// </summary> public static bool UpdateComment(int id, string body) { CommentDetails record = new CommentDetails( id, DateTime.Now, "", "", "", 0, "", body); bool ret = SiteProvider.Articles.UpdateComment(record); BizObject.PurgeCacheItems("articles_comment"); return(ret); }
/// <summary> /// Creates a new comment /// </summary> public static int InsertComment(string addedBy, string addedByEmail, int articleID, string body) { CommentDetails record = new CommentDetails(0, DateTime.Now, addedBy, addedByEmail, BizObject.CurrentUserIP, articleID, "", body); int ret = SiteProvider.Articles.InsertComment(record); BizObject.PurgeCacheItems("articles_comment"); return(ret); }
public bool AssertMatch(CommentDetails commentDetails, long commentId, string text, long authorId, string authorName) { Assert.AreEqual(commentId, commentDetails.CommentId); Assert.AreEqual(text, commentDetails.Text); Assert.AreEqual(authorId, commentDetails.AuthorId); Assert.AreEqual(authorName, commentDetails.AuthorName); return(true); }
//public override async Task<string> FetchComments(Data.Entity.Comment comment) public override async Task <CommentDetails> FetchComments(Data.Entity.Comment comment) { _logger.LogInformation($"Youtube Started: {comment.Url}"); #region initialize var videoId = GetVideoId(comment.Url); var query = BuildQuery(videoId); var response = await _httpClient.GetAsync(query); #endregion #region Failed Fetch if (response.StatusCode == HttpStatusCode.Forbidden) { _logger.LogInformation($"Youtube: {response.StatusCode.ToString()}"); return(default(CommentDetails)); } #endregion #region needed params var fileName = Guid.NewGuid().ToString().Replace("-", "").ToUpper() + ".csv"; var currentResponse = new YouTubeCommentSet(); bool hasMore = false; string nextPageToken = ""; var refinedComments = new List <RefinedComment>(); #endregion do { if (hasMore) { var newQuery = AddNextPageToken(query, nextPageToken); response = await _httpClient.GetAsync(newQuery); } currentResponse = await response.Content.ReadAsAsync <YouTubeCommentSet>(); var snippets = currentResponse.Items.Select(e => GetRefinedComment(e, videoId)); refinedComments.AddRange(snippets); nextPageToken = currentResponse.NextPageToken; hasMore = !string.IsNullOrEmpty(nextPageToken); } while (hasMore); var fileSaved = SaveToFile(fileName, refinedComments); _logger.LogInformation($"fetching successfull for {comment.Url}, {response.StatusCode}"); var details = new CommentDetails { Filename = fileSaved ? fileName : "", Name = await VideoName(videoId), NOC = refinedComments.Count }; return(details); //return fileSaved ? fileName : ""; }
/// <summary> /// Updates an comment /// </summary> public override bool UpdateComment(CommentDetails comment) { using (SqlConnection cn = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("tbh_Articles_UpdateComment", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@CommentID", SqlDbType.Int).Value = comment.ID; cmd.Parameters.Add("@Body", SqlDbType.NVarChar).Value = comment.Body; cn.Open(); int ret = ExecuteNonQuery(cmd); return(ret == 1); } }
/// <summary> /// Returns a Comment object filled with the data taken from the input CommentDetails /// </summary> private static Comment GetCommentFromCommentDetails(CommentDetails record) { if (record == null) { return(null); } else { return(new Comment(record.ID, record.AddedDate, record.AddedBy, record.AddedByEmail, record.AddedByIP, record.ArticleID, record.ArticleTitle, record.Body)); } }
/// <summary> /// Insert Comment on documents /// </summary> /// <param name="comment">Comment</param> /// <param name="headerExpanderContentGridCommentGrid">Grid</param> private void InsertComment_Documents(CommentDetails comment, Grid headerExpanderContentGridCommentGrid) { if (comment.Comment != null) { headerExpanderContentGridCommentGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); #region Comment On TextBlock commentOnTextBlock = new TextBlock() { Text = comment.CommentOn.ToLocalTime().ToString("MMMM dd, yyyy"), VerticalAlignment = System.Windows.VerticalAlignment.Center, Margin = new Thickness(5, 0, 0, 0), Style = (Style)(this.Resources["TextBlockStyle"]) }; commentOnTextBlock.SetValue(Grid.RowProperty, headerExpanderContentGridCommentGrid.RowDefinitions.Count - 1); commentOnTextBlock.SetValue(Grid.ColumnProperty, 0); #endregion #region Comment By TextBlock commentByTextBlock = new TextBlock() { Text = comment.CommentBy, VerticalAlignment = System.Windows.VerticalAlignment.Center, Margin = new Thickness(5, 0, 0, 0), Style = (Style)(this.Resources["TextBlockStyle"]) }; commentByTextBlock.SetValue(Grid.RowProperty, headerExpanderContentGridCommentGrid.RowDefinitions.Count - 1); commentByTextBlock.SetValue(Grid.ColumnProperty, 1); #endregion #region Comment TextBlock commentTextBlock = new TextBlock() { Text = comment.Comment, VerticalAlignment = System.Windows.VerticalAlignment.Center, Margin = new Thickness(5, 0, 5, 0), Style = (Style)(this.Resources["TextBlockStyle"]) }; #endregion commentTextBlock.SetValue(Grid.RowProperty, headerExpanderContentGridCommentGrid.RowDefinitions.Count - 1); commentTextBlock.SetValue(Grid.ColumnProperty, 2); headerExpanderContentGridCommentGrid.Children.Add(commentOnTextBlock); headerExpanderContentGridCommentGrid.Children.Add(commentByTextBlock); headerExpanderContentGridCommentGrid.Children.Add(commentTextBlock); } }
public void GetCommentTest() { /* Initialization */ UserProfile user = testUtil.CreateTestUser(); Link link = testUtil.CreateTestLink(user); Comment comment = testUtil.CreateTestComment(user, link); /* Use case */ CommentDetails actual = commentService.GetComment(comment.commentId); /* Check */ testUtil.AssertMatch(comment, actual); }
//利用深度优先搜索,将数据库中相应的搜索查询出来并封装 public async Task dfs(CommentDetails comment) { //查询所有当前评论的子评论 var comment2 = from b in _context.mb_comment select b; comment2 = comment2.Where(m => m.comment_id == comment.comment.ID); List <mb_comment> mb_comment = await comment2.AsNoTracking().ToListAsync(); foreach (var item in mb_comment) { mb_user user = await _context.mb_user.SingleOrDefaultAsync(b => b.User_id == item.User_publish); CommentDetails m = new CommentDetails(item, user); comment.listnum++; comment.listson.Add(m); await dfs(comment.listson[comment.listnum - 1]); } }
/// <summary> /// Inserts a new comment /// </summary> public override int InsertComment(CommentDetails comment) { using (SqlConnection cn = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("tbh_Articles_InsertComment", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@AddedDate", SqlDbType.DateTime).Value = comment.AddedDate; cmd.Parameters.Add("@AddedBy", SqlDbType.NVarChar).Value = comment.AddedBy; cmd.Parameters.Add("@AddedByEmail", SqlDbType.NVarChar).Value = comment.AddedByEmail; cmd.Parameters.Add("@AddedByIP", SqlDbType.NVarChar).Value = comment.AddedByIP; cmd.Parameters.Add("@ArticleID", SqlDbType.Int).Value = comment.ArticleID; cmd.Parameters.Add("@Body", SqlDbType.NVarChar).Value = comment.Body; cmd.Parameters.Add("@CommentID", SqlDbType.Int).Direction = ParameterDirection.Output; cn.Open(); int ret = ExecuteNonQuery(cmd); return((int)cmd.Parameters["@CommentID"].Value); } }
private async Task FetchAndSendRequests(CommentsDbContext dbContext) { var requests = await dbContext.Comments.Where(cr => !cr.Fetched && !cr.Disabled).ToListAsync(); if (requests.Any()) { foreach (var request in requests) { _logger.LogInformation($"Db Fetch Request ID: {request.ToString()}"); var host = new Uri(request.Url)?.Host; _logger.LogInformation($"Host: {host}"); CommentDetails result = new CommentDetails(); switch (host) { case AppConstants.YoutubeHost: _logger.LogInformation("Hello Youtube"); result = await _fetcherFactory(AppConstants.Youtube).FetchComments(request); break; case AppConstants.AmazonHost: _logger.LogInformation("Hello Amazon"); result = await _fetcherFactory(AppConstants.Amazon).FetchComments(request); break; default: _logger.LogInformation("We haven't implemented that yet"); break; } request.Fetched = result?.Filename == null ? false : true; request.Location = result?.Filename; request.NOC = result?.NOC; request.Name = result?.Name; request.UpdatedDate = DateTime.UtcNow; request.Disabled = result == null ? true : false; dbContext.Attach(request); dbContext.Entry(request).State = EntityState.Modified; _logger.LogInformation($"Comment Download Successfull: {request.ToString()}"); await dbContext.SaveChangesAsync(); } } }
public async Task <CommentDetails> GetCommentDetialsAsync(string commentId, string currentUserId) { return(await Task.Run(async() => { var comment = comments.FirstOrDefault(x => x.Id == commentId); var commentDetails = new CommentDetails() { ArticleId = comment.ArticleId, CommentText = comment.CommentText, Id = comment.Id, UpdatedOn = comment.UpdatedOn, ParentId = comment.ParentId, ChildrenCommentsCount = 0, Ranking = await GetCommentRankingDetailsAsync(commentId, currentUserId), User = await GetUserAsync(comment.UserId) }; return commentDetails; })); }
protected void Page_Load(object sender, EventArgs e) { CommentId = Int64.Parse(Request.Params.Get("commentId")); IUnityContainer container = (IUnityContainer)HttpContext.Current.Application["unityContainer"]; ICommentService commentService = container.Resolve <ICommentService>(); ILinkService linkService = container.Resolve <ILinkService>(); CommentDetails comment = commentService.GetComment(CommentId); LinkDetails link = linkService.GetLink(comment.LinkId); MovieId = link.MovieId; lblLink.Text = link.Name; lnkLink.NavigateUrl = Response.ApplyAppPathModifier("~/Pages/Link/Link.aspx?linkId=" + link.LinkId); lblAuthor.Text = comment.AuthorName; lnkAuthor.NavigateUrl = Response.ApplyAppPathModifier("~/Pages/Comment/ListComments.aspx?userId=" + comment.AuthorId); lblDate.Text = comment.Date.ToString(); lblText.Text = comment.Text; }
public async Task <IHttpActionResult> Post(int ticketId, [FromBody] CommentDetails model) { var ticket = await taskManagerUow.Tickets.FindByIdAsync(ticketId, false, false); if (ticket == null) { return(NotFound()); } bool success = await taskManagerUow.Comments.SaveNewAsync(model, User, args : ticket); if (success) { await taskManagerUow.FilesBase.AddFilesLocal(model); var comment = await taskManagerUow.Comments.FindByIdAsync <CommentDTO>(model.Id); return(CreatedAtRoute("GetComment", new { id = comment.Id }, comment)); } return(this.Forbid()); }
public string Remove(long commentId) { IUnityContainer container = (IUnityContainer)HttpContext.Current.Application["unityContainer"]; ICommentService commentService = container.Resolve <ICommentService>(); ILinkService linkService = container.Resolve <ILinkService>(); CommentDetails comment = commentService.GetComment(commentId); long commentLinkAuthorId = comment.AuthorId; LinkDetails link = linkService.GetLink(comment.LinkId); UserSession userSession = (UserSession)this.Context.Session["userSession"]; long userId = userSession.UserProfileId; if ((comment.AuthorId == userId) || (link.UserId == userId)) { return("<a href=\"/Pages/Comment/RemoveComment.aspx?commentId=" + commentId + "\"><img src=\"" + GetLocalResourceObject("lnkRemoveComment.ImageUrl") + "\" alt=\"" + GetLocalResourceObject("lnkRemoveComment.AlternateText") + "\" /></a>"); } else { return(""); } }
/// <summary> /// Gets all the comments for the specified Content. /// </summary> /// <param name="filter">Filter which comments to be fetched</param> /// <param name="pageDetails">Details about the pagination</param> /// <returns>List of all comments of the Content</returns> public async Task <IEnumerable <CommentDetails> > GetContentComments(CommentFilter filter, PageDetails pageDetails) { this.CheckNotNull(() => new { filter, pageDetails }); Func <ContentComments, object> orderBy = (contentComments) => contentComments.CommentDatetime; Expression <Func <ContentComments, bool> > condition = (contentComments) => contentComments.ContentID == filter.EntityId && contentComments.IsDeleted == false; IEnumerable <ContentComments> comments = _contentCommentsRepository .GetItems(condition, orderBy, filter.OrderType == OrderType.NewestFirst, (pageDetails.CurrentPage - 1) * pageDetails.ItemsPerPage, pageDetails.ItemsPerPage); var commentDetails = new List <CommentDetails>(); if (comments != null) { foreach (var item in comments) { var comment = new CommentDetails(); Mapper.Map(item, comment); commentDetails.Add(comment); } } return(commentDetails); }
public bool CreateContentComment(CommentDetails comment) { // Make sure input is not null this.CheckNotNull(() => new { comment }); try { var contentComment = new ContentComments(); Mapper.Map(comment, contentComment); contentComment.IsDeleted = false; contentComment.CommentDatetime = DateTime.UtcNow; _contentCommentsRepository.Add(contentComment); _contentCommentsRepository.SaveChanges(); return(true); } catch (Exception) { // TODO: Add exception handling logic here. } return(false); }
public bool AssertMatch(CommentDetails commentDetails, long commentId, string text, long authorId, string authorName, DateTime date) { Assert.AreEqual(date, commentDetails.Date); return(AssertMatch(commentDetails, commentId, text, authorId, authorName) && true); }
public override async Task <CommentDetails> FetchComments(Comment comment) { var refinedComments = new List <RefinedComment>(); var fileName = Guid.NewGuid().ToString().Replace("-", "").ToUpper() + ".csv"; var title = ""; var webScrap = new HtmlWeb(); webScrap.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"; var hasMore = false; var count = 1; do { #region Initialize if (hasMore) { comment.Url = comment.Url + "/?pageNumber=" + count.ToString(); } var htmlScrap = await webScrap.LoadFromWebAsync(comment.Url); var author = htmlScrap.DocumentNode.CssSelect(".author").ToList(); var date = htmlScrap.DocumentNode.CssSelect(".review-date").ToList(); var rate = htmlScrap.DocumentNode.CssSelect("i.review-rating > span").ToList(); var text = htmlScrap.DocumentNode.CssSelect(".review-text").ToList(); var last = htmlScrap.DocumentNode.CssSelect(".a-disabled.a-last").FirstOrDefault(); if (!hasMore) { title = htmlScrap.DocumentNode.CssSelect("title").FirstOrDefault().InnerHtml; } #endregion #region Nomalize var authorNo = author.Count; var dateNo = date.Count; var rateNo = rate.Count; var textNo = text.Count; if (authorNo > textNo) { author = author.Skip(authorNo - textNo).ToList(); } if (dateNo > textNo) { date = date.Skip(dateNo - textNo).ToList(); } if (rateNo > textNo) { rate = rate.Skip(rateNo - textNo).ToList(); } #endregion #region Add To RefinedComment for (int i = 0; i < textNo; i++) { refinedComments.Add(new RefinedComment { Comment = text[i].InnerHtml, Date = date[i].InnerHtml.Replace("on ", ""), Link = "", Rating = rate[i].InnerHtml, Username = author[i].InnerHtml, }); } #endregion count++; hasMore = last == null ? false : true; } while (hasMore); var fileSaved = SaveToFile(fileName, refinedComments); _logger.LogInformation($"fetching successfull for {comment.Url}, {webScrap.StatusCode}"); var details = new CommentDetails { Filename = fileSaved ? fileName : "", Name = title, NOC = refinedComments.Count }; return(details); }
public bool AssertMatch(Comment comment, CommentDetails commentDetails) { return(AssertMatch(commentDetails, comment.commentId, comment.text, comment.UserProfile.userId, comment.UserProfile.userLogin, comment.date)); }
public CommentDetails SelLatestCommentsByStatusId(Guid StatusId) { CommentDetails objCommentDetails = null; try { DbParam[] param = new DbParam[] { new DbParam("@StatusId",StatusId,SqlDbType.UniqueIdentifier) }; ds = Db.GetDataSet("proc_tblComment_SelLatestComments", param); if (ds != null) { objCommentDetails = new CommentDetails(); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { objComments = new List<Comment>(); foreach (DataRow row in ds.Tables[0].Rows) objComments.Add(GetObject(row)); objCommentDetails.CommentList = objComments; } if (ds.Tables.Count > 1 && ds.Tables[1].Rows.Count > 0) { objCommentDetails.PageCount = Db.ToInteger(ds.Tables[1].Rows[0]["TotalCount"]); } } } catch { } return objCommentDetails; }
/// <summary> /// Updates an comment /// </summary> public override bool UpdateComment(CommentDetails comment) { using (SqlConnection cn = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("tbh_Articles_UpdateComment", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@CommentID", SqlDbType.Int).Value = comment.ID; cmd.Parameters.Add("@Body", SqlDbType.NVarChar).Value = comment.Body; cn.Open(); int ret = ExecuteNonQuery(cmd); return (ret == 1); } }
/// <summary> /// Inserts a new comment /// </summary> public override int InsertComment(CommentDetails comment) { using (SqlConnection cn = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("tbh_Articles_InsertComment", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@AddedDate", SqlDbType.DateTime).Value = comment.AddedDate; cmd.Parameters.Add("@AddedBy", SqlDbType.NVarChar).Value = comment.AddedBy; cmd.Parameters.Add("@AddedByEmail", SqlDbType.NVarChar).Value = comment.AddedByEmail; cmd.Parameters.Add("@AddedByIP", SqlDbType.NVarChar).Value = comment.AddedByIP; cmd.Parameters.Add("@ArticleID", SqlDbType.Int).Value = comment.ArticleID; cmd.Parameters.Add("@Body", SqlDbType.NVarChar).Value = comment.Body; cmd.Parameters.Add("@CommentID", SqlDbType.Int).Direction = ParameterDirection.Output; cn.Open(); int ret = ExecuteNonQuery(cmd); return (int)cmd.Parameters["@CommentID"].Value; } }