public ActionResult Detail(string key) { ViewBag.VideoHeight = (Request.Browser.IsMobileDevice) ? 190 : 400; ViewBag.VideoWidth = (Request.Browser.IsMobileDevice) ? 285 : 600; var model = new BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content(key); ViewBag.ThumbIcon = Utilities.S3ContentPath(model.ContentPhotoThumbURL); LoadTagCloud(); ContentComment concom = new ContentComment(); BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content otherNews = new BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content(); otherNews.GetPreviousNews(model.ReleaseDate ); if (otherNews.ContentID > 0 ) { ViewBag.PreviousNews = otherNews.ToUnorderdListItem; } otherNews = new BootBaronLib.AppSpec.DasKlub.BOL.UserContent.Content(); otherNews.GetNextNews(model.ReleaseDate ); if (otherNews.ContentID > 0) { ViewBag.NextNews = otherNews.ToUnorderdListItem; } return View(model); }
public ContentComment SaveComment(ContentComment comment) { using (var context = new Data.CMSContext()) { ContentComment oldComment = context.ContentComments.SingleOrDefault(c => c.CommentUId == comment.CommentUId); if (oldComment == null) { context.ContentComments.Add(comment); int? position = context.ContentComments.Where(c => c.ContentUId == comment.ContentUId).Max(c => (int?) c.Position); if (position == null) comment.Position = 0; else comment.Position = position.Value + 1; } else { context.ContentComments.Attach(oldComment); context.Entry<ContentComment>(oldComment).CurrentValues.SetValues(comment); } context.SaveChanges(); IncreaseCommentCount(comment); return comment; } }
/* * TRI-28062016 Update like number from table dbo.ContentComment * commentId: ID of comment * fullName: Full name of logged user * email: Email of logged user (default is empty string) * cms_db: DataModel Controller * userId: ID of logged user */ public async Task <int> LikeComments(int commentId, string fullName, string email, Ctrl cms_db, long userId) { ContentComment comment = db.ContentComments.SingleOrDefault(a => a.CommentId == commentId); if (comment != null) { int newLikeCount = 1; if (comment.LikeCount != null) { newLikeCount = (int)comment.LikeCount + 1; } comment.LikeCount = newLikeCount; try { await db.SaveChangesAsync(); return(newLikeCount); } catch (Exception ex) { Core core = new Core(); core.AddToExceptionLog("LikeComments", "ProductController", "Like comment error: " + ex.Message, userId); return(0); } } else { return(0); } }
public bool SubmitComment(PostCommentInputViewModel commentInputViewModel, Guid userId) { Guid contentId = new Guid(commentInputViewModel.ContentId); Content content = UnitOfWork.ContentRepository.GetById(contentId); if (content == null) { return(false); } ContentComment oContentComment = new ContentComment() { UserId = userId, ContentId = contentId, Comment = commentInputViewModel.Comment, IsActive = true }; UnitOfWork.ContentCommentRepository.Insert(oContentComment); content.CommentCount = content.CommentCount + 1; UnitOfWork.ContentRepository.Update(content); UnitOfWork.Save(); return(true); }
public ContentComment SaveComment(ContentComment comment) { using (var context = new Data.CMSContext()) { ContentComment oldComment = context.ContentComments.SingleOrDefault(c => c.CommentUId == comment.CommentUId); if (oldComment == null) { context.ContentComments.Add(comment); int?position = context.ContentComments.Where(c => c.ContentUId == comment.ContentUId).Max(c => (int?)c.Position); if (position == null) { comment.Position = 0; } else { comment.Position = position.Value + 1; } } else { context.ContentComments.Attach(oldComment); context.Entry <ContentComment>(oldComment).CurrentValues.SetValues(comment); } context.SaveChanges(); IncreaseCommentCount(comment); return(comment); } }
/* * TRI-28062016 Add reply to comment * productId: ID of Product * replyContent: Reply contains from user * commentId: ID of comment * fullName: Full name of logged user * email: Email of logged user (default is empty string) * cms_db: DataModel Controller * userId: ID of logged user */ public async Task <ObjContentComment> ReplyComments(long productId, string replyContent, int commentId, string fullName, string email, Ctrl cms_db, long userId) { if (fullName.Length > 250) { fullName = fullName.Substring(0, 249); //To make it fix to column data type length } if (email.Length > 250) { email = email.Substring(0, 249); //To make it fix to column data type length } Product product = cms_db.GetObjProductById(productId); Classification classification = cms_db.GetObjClasscifiById((int)Extension.EnumCore.StateType.cho_duyet); if (product != null) { ContentComment comment = new ContentComment(); comment.ParentCommentId = commentId; comment.ContentObjId = productId; comment.ContentObjName = product.ProductName; comment.Title = null; comment.CommentText = StripHTMLAndScript(replyContent); //Keep comment clearn without html injection comment.FullName = fullName; comment.EmailAddress = email; comment.CrtdDT = DateTime.Now; comment.AprvdDT = null; comment.AprvdUID = null; comment.AprvdUerName = null; comment.StateId = classification.ClassificationId; comment.StateName = classification.ClassificationNM; comment.CrtdGuestUserId = null; comment.LikeCount = null; comment.LastLikedDT = null; comment.IPAddress = GetIPAddress(); comment.ObjTypeId = (int)Extension.EnumCore.ObjTypeId.san_pham; comment.ObjTypeName = "san_pham"; try { await cms_db.AddComment(comment); ObjContentComment objContentComment = GetCommentById(comment.CommentId, cms_db, userId); return(objContentComment); } catch (Exception ex) { Core core = new Core(); core.AddToExceptionLog("ReplyComments", "ProductController", "Save reply on comment error: " + ex.Message, userId); return(null); } } else { return(null); } }
private void IncreaseCommentCount(ContentComment comment) { using (var context = new Data.CMSContext()) { ContentCommentCount oldCount = context.ContentCommentCounts.SingleOrDefault(c => c.ContentUId == comment.ContentUId); if (oldCount == null) context.ContentCommentCounts.Add(new ContentCommentCount() { ContentUId = comment.ContentUId, Count = 1 }); else oldCount.Count++; context.SaveChanges(); } }
public ActionResult Edit(ContentComment contentcomment) { if (ModelState.IsValid) { db.Entry(contentcomment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TopicId = new SelectList(db.ContentTopics, "Id", "Title", contentcomment.TopicId); ViewBag.UserId = new SelectList(db.MemberUsers, "Id", "UserName", contentcomment.UserId); return(View(contentcomment)); }
public IEnumerable<ContentComment> Post([FromBody] ContentComment comment, bool returnNewPosts = false, int lastCommentPosition = 0, string order = "DESC") { comment.CommentUId = Guid.NewGuid().ToString(); comment.CommentDate = DateTime.Now.ToUniversalTime(); cms.SaveComment(comment); if(!returnNewPosts) return new ContentComment[] { comment }; return cms.GetComments(comment.ContentUId, lastCommentPosition, 0, 0, order, false); }
public async Task <int> AddComment(ContentComment ObjComment) { try { db.ContentComments.Add(ObjComment); return(await db.SaveChangesAsync()); } catch (Exception e) { this.AddToExceptionLog("AddComment", "CoreCtrl_comment", e.ToString()); return((int)EnumCore.Result.action_false); } }
public ActionResult DeleteConfirmed(Guid?id) { if (!id.HasValue) { return(HttpNotFound()); } ContentComment contentcomment = db.ContentComments.Find(id.Value); db.ContentComments.Remove(contentcomment); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(ContentComment contentcomment) { if (ModelState.IsValid) { contentcomment.Id = Guid.NewGuid(); db.ContentComments.Add(contentcomment); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TopicId = new SelectList(db.ContentTopics, "Id", "Title", contentcomment.TopicId); ViewBag.UserId = new SelectList(db.MemberUsers, "Id", "UserName", contentcomment.UserId); return(View(contentcomment)); }
// // GET: /Comment/Delete/5 public ActionResult Delete(Guid?id = null) { if (!id.HasValue) { return(HttpNotFound()); } ContentComment contentcomment = db.ContentComments.Find(id.Value); if (contentcomment == null) { return(HttpNotFound()); } return(View(contentcomment)); }
public ActionResult DeleteComment(int commentID) { var model = new ContentComment(commentID); var content = new Content(model.ContentID); var ua = new UserAccount(Convert.ToInt32(_mu.ProviderUserKey)); if (_mu == null || (model.CreatedByUserID != Convert.ToInt32(_mu.ProviderUserKey) && !ua.IsAdmin)) return new EmptyResult(); model.Delete(); return RedirectToAction("Detail", new {@key = content.ContentKey}); }
public ActionResult TopicItem(TopicViewModel topicViewModel) { ContentTopic topic = db.ContentTopics.Find(topicViewModel.Topic.Id); ContentComment post = db.ContentComments.Find(topic.FirstCommentId); topic.IsHidden = topicViewModel.Topic.IsHidden; topic.IsSticky = topicViewModel.Topic.IsSticky; topic.IsLocked = topicViewModel.Topic.IsLocked; db.SaveChanges(); topicViewModel.Topic = topic; topicViewModel.Post = post; return(PartialView("_TopicItem", topicViewModel)); }
/// <summary> /// SaveContentComment /// </summary> /// <param name="contentCommentRequest"></param> /// <returns></returns> public ServiceResponse <int> SaveContentComment(ContentCommentDC contentCommentRequest) { ServiceResponse <int> contentCommentResponse = new ServiceResponse <int>(); try { SetContext(); ContentComment comment = Mapper.Map <ContentCommentDC, ContentComment>(contentCommentRequest); _contentManager.SaveContentComment(comment); contentCommentResponse.Result = comment.ContentCommentId; } catch (Exception ex) { HandleError(ex, contentCommentResponse); } return(contentCommentResponse); }
// // GET: /Comment/Edit/5 public ActionResult Edit(Guid?id = null) { if (!id.HasValue) { return(HttpNotFound()); } ContentComment contentcomment = db.ContentComments.Find(id.Value); if (contentcomment == null) { return(HttpNotFound()); } ViewBag.TopicId = new SelectList(db.ContentTopics, "Id", "Title", contentcomment.TopicId); ViewBag.UserId = new SelectList(db.MemberUsers, "Id", "UserName", contentcomment.UserId); return(View(contentcomment)); }
public ActionResult CommentItem(TopicViewModel commentViewModel) { ContentComment commentItem = db.ContentComments.Find(commentViewModel.Post.Id); commentItem.IsHidden = commentViewModel.Post.IsHidden; commentItem.IsSpam = commentViewModel.Post.IsSpam; commentItem.IsLocked = commentViewModel.Post.IsLocked; commentItem.IsSolution = commentViewModel.Post.IsSolution; db.SaveChanges(); commentViewModel.Post = commentItem; ContentTopic topic = db.ContentTopics.Find(commentViewModel.Post.TopicId); commentViewModel.Topic = topic; return(PartialView("_CommentItem", commentViewModel)); }
private void IncreaseCommentCount(ContentComment comment) { using (var context = new Data.CMSContext()) { ContentCommentCount oldCount = context.ContentCommentCounts.SingleOrDefault(c => c.ContentUId == comment.ContentUId); if (oldCount == null) { context.ContentCommentCounts.Add(new ContentCommentCount() { ContentUId = comment.ContentUId, Count = 1 }); } else { oldCount.Count++; } context.SaveChanges(); } }
/// <summary> /// Updates the specified site id. /// </summary> /// <param name="siteId">The site id.</param> /// <param name="contentComment">The content comment.</param> /// <param name="commentTable">The comment table.</param> public static void Update(Guid siteId, ContentComment contentComment, CommentTables commentTable) { using (var connection = new SqlConnection(Settings.ADONetConnectionString)) { connection.Open(); var query = string.Format("UPDATE {0} " + "SET Comment = @Comment, IsOfficialAnswer = @IsOfficialAnswer" + " WHERE ID = @ID AND SiteID = @SiteID", commentTable.ToString()); using (var command = new SqlCommand(query, connection)) { command.Parameters.AddWithValue("@ID", contentComment.ID); command.Parameters.AddWithValue("@SiteID", siteId); command.Parameters.AddWithValue("@Comment", contentComment.Comment); command.Parameters.AddWithValue("@IsOfficialAnswer", contentComment.IsOfficialAnswer); command.ExecuteNonQuery(); } } }
public async Task <int> UpdateStateComment(int id, int state, DateTime AppDt, string AppName, long AppId) { ContentComment result = db.ContentComments.SingleOrDefault(a => a.CommentId == id); if (result != null) { result.StateId = state; result.AprvdDT = AppDt; result.AprvdUID = AppId; result.AprvdUerName = AppName; if (result.StateId == (int)EnumCore.StateType.cho_phep) { result.StateName = "Enable"; } if (result.StateId == (int)EnumCore.StateType.khong_cho_phep) { result.StateName = "Disable"; } db.Entry(result).State = EntityState.Modified; } return(await db.SaveChangesAsync()); }
public ContentCommentViewModels(ContentComment model) { _ModelObj = model; }
public ContentCommentViewModels() { _ModelObj = new ContentComment(); }
public ActionResult BlockIP(int? id) { if (id != null && id > 0) { var model = new ContentComment( Convert.ToInt32(id)); model.Delete(); var bip = new BlackIP {IpAddress = model.IpAddress}; bip.Create(); } return RedirectToAction("ArticleComments"); }
public ActionResult EditArticleComment(int? id) { var model = new ContentComment(); if (id != null && id > 0) { model = new ContentComment( Convert.ToInt32(id)); } return View(model); }
public ActionResult EditArticleComment( FormCollection fc, int? contentCommentID) { var model = new ContentComment(); if (contentCommentID != null && contentCommentID > 0) { model = new ContentComment( Convert.ToInt32(contentCommentID)); } TryUpdateModel(model); if (!ModelState.IsValid) { return View(model); } model.Update(); return RedirectToAction("ArticleComments"); }
public ActionResult DeleteComment(int? id) { if (id != null && id > 0) { var model = new ContentComment( Convert.ToInt32(id)); model.Delete(); } return RedirectToAction("ArticleComments"); }
public int UpdateContentComment(ContentComment com) { db.Entry <ContentComment>(com).State = EntityState.Modified; return(db.SaveChanges()); }
/* * Method save comment of user * productId: product id * comments: comment from logged user * fullName: full name of logged user (default is empty string) * email: email of logged user (default is empty string) * cms_db: Controll class from DataMode.DataStore * userId: Id of logged user */ public async Task <int> SaveComments(long idObject, string comments, string fullName, string email, Ctrl cms_db, long userId, int objType, string objTypeName, long parentId) { if (fullName.Length > 250) { fullName = fullName.Substring(0, 249); //To make it fix to column data type length } if (email.Length > 250) { email = email.Substring(0, 249); //To make it fix to column data type length } if (objType == (int)EnumCore.ObjTypeId.san_pham) { Product product = cms_db.GetObjProductById(idObject); Classification classification = cms_db.GetObjClasscifiById((int)Extension.EnumCore.StateType.cho_duyet); if (product != null) { ContentComment comment = new ContentComment(); comment.ParentCommentId = parentId; comment.ContentObjId = idObject; comment.ContentObjName = product.ProductName; comment.Title = null; comment.CommentText = StripHTMLAndScript(comments); //Keep comment clearn without html injection comment.FullName = fullName; comment.EmailAddress = email; comment.CrtdDT = DateTime.Now; comment.AprvdDT = null; comment.AprvdUID = null; comment.AprvdUerName = null; comment.StateId = classification.ClassificationId; comment.StateName = classification.ClassificationNM; comment.CrtdGuestUserId = null; comment.LikeCount = null; comment.LastLikedDT = null; comment.IPAddress = GetIPAddress(); comment.ObjTypeId = objType; comment.ObjTypeName = objTypeName; try { return(await cms_db.AddComment(comment)); } catch (Exception ex) { Core core = new Core(); core.AddToExceptionLog("SaveComments", "ProductController", "Create comment error: " + ex.Message, userId); return(0); } } else { return(0); } } else { Microsite mic = cms_db.GetObjMicrositeByID(idObject); if (mic != null) { ContentComment comment = new ContentComment(); comment.ParentCommentId = parentId; comment.ContentObjId = idObject; comment.ContentObjName = mic.Name; comment.Title = null; comment.CommentText = StripHTMLAndScript(comments); //Keep comment clearn without html injection comment.FullName = fullName; comment.EmailAddress = email; comment.CrtdDT = DateTime.Now; comment.AprvdDT = null; comment.AprvdUID = null; comment.AprvdUerName = null; comment.StateId = (int)EnumCore.StateType.cho_phep; comment.StateName = "Cho phép"; comment.CrtdGuestUserId = null; comment.LikeCount = null; comment.LastLikedDT = null; comment.IPAddress = GetIPAddress(); comment.ObjTypeId = objType; comment.ObjTypeName = objTypeName; try { return(await cms_db.AddComment(comment)); } catch (Exception ex) { Core core = new Core(); core.AddToExceptionLog("SaveComments", "ProductController", "Create comment error: " + ex.Message, userId); return(0); } } return(0); } }
public ContentComment GetObjComment(long CommentID) { ContentComment ObjComment = db.ContentComments.Find(CommentID); return(ObjComment); }
/// <summary> /// Adds the specified site id. /// </summary> /// <param name="siteId">The site id.</param> /// <param name="userId">The user id.</param> /// <param name="contentId">The content id.</param> /// <param name="commentText">The comment text.</param> /// <param name="destiantionUserId">The destiantion user id.</param> /// <param name="replyToCommentId">The reply to comment id.</param> /// <param name="fileName">Name of the file.</param> /// <param name="commentTable">The comment table.</param> /// <param name="isOfficialAnswer">if set to <c>true</c> [is official answer].</param> /// <param name="sendNotification">if set to <c>true</c> [send notification].</param> /// <param name="isInternal">if set to <c>true</c> [is internal].</param> /// <returns></returns> public static ContentComment Add(Guid siteId, Guid userId, Guid contentId, string commentText, Guid?destiantionUserId, Guid?replyToCommentId, string fileName, CommentTables commentTable, bool isOfficialAnswer, bool sendNotification, bool isInternal = false) { if (string.IsNullOrEmpty(commentText.Trim()) && string.IsNullOrEmpty(fileName)) { return(null); } var result = new ContentComment(); using (var connection = new SqlConnection(Settings.ADONetConnectionString)) { connection.Open(); var id = Guid.NewGuid(); var query = string.Format("INSERT INTO {0} ([ID], [SiteId], [ContentID], [UserID], [DestinationUserID], [ReplyToID], [Comment], [FileName], [IsOfficialAnswer], [IsInternal]) " + "VALUES (@ID, @SiteID, @ContentID, @UserID, @DestinationUserID, @ReplyToID, @Comment, @FileName, @IsOfficialAnswer, @IsInternal) " + "SELECT c.ID, c.ContentID, c.UserID, c.CreatedAt, contact.UserFullName, dcontact.UserFullName as DestinationUserFullName, c.Comment, c.IsOfficialAnswer, c.IsInternal, c.FileName " + "FROM {0} as c " + "LEFT JOIN tbl_User as u ON c.UserID = u.ID " + "LEFT JOIN tbl_Contact as contact ON u.ContactID = contact.ID " + "LEFT JOIN tbl_User as du ON c.DestinationUserID = du.ID " + "LEFT JOIN tbl_Contact as dcontact ON du.ContactID = dcontact.ID " + "WHERE c.ID = @ID", commentTable.ToString()); using (var command = new SqlCommand(query, connection)) { command.Parameters.AddWithValue("@ID", id); command.Parameters.AddWithValue("@SiteID", siteId); command.Parameters.AddWithValue("@ContentID", contentId); command.Parameters.AddWithValue("@UserID", userId); command.Parameters.AddWithValue("@IsInternal", isInternal); if (destiantionUserId.HasValue) { command.Parameters.AddWithValue("@DestinationUserID", destiantionUserId); } else { command.Parameters.AddWithValue("@DestinationUserID", DBNull.Value); } if (replyToCommentId.HasValue) { command.Parameters.AddWithValue("@ReplyToID", replyToCommentId); } else { command.Parameters.AddWithValue("@ReplyToID", DBNull.Value); } command.Parameters.AddWithValue("@Comment", commentText); command.Parameters.AddWithValue("@FileName", fileName); command.Parameters.AddWithValue("@IsOfficialAnswer", isOfficialAnswer); using (var reader = command.ExecuteReader()) { if (reader.HasRows) { reader.Read(); result.ID = (Guid)reader["ID"]; result.ContentID = (Guid)reader["ContentID"]; result.UserID = (Guid)reader["UserID"]; result.FormattedDate = ((DateTime)reader["CreatedAt"]).ToString("d MMMM в HH:mm"); result.UserFullName = reader["UserFullName"] != DBNull.Value ? (string)reader["UserFullName"] : null; result.DestinationUserFullName = reader["DestinationUserFullName"] != DBNull.Value ? (string)reader["DestinationUserFullName"] : null; result.Comment = reader["Comment"] != DBNull.Value ? ((string)reader["Comment"]).ToHtml() : null; result.IsOfficialAnswer = reader["IsOfficialAnswer"] != DBNull.Value && (bool)reader["IsOfficialAnswer"]; result.IsInternal = reader["IsInternal"] != DBNull.Value && (bool)reader["IsInternal"]; result.FileName = reader["FileName"] != DBNull.Value ? (string)reader["FileName"] : null; result.SumLike = 0; result.ContactLike = false; } } } } var fsp = new FileSystemProvider(); if (!string.IsNullOrEmpty(result.FileName)) { result.VirtualFileName = fsp.GetLink(siteId, EnumHelper.GetEnumDescription(commentTable), result.FileName, FileType.Attachment); } if (sendNotification) { var dataManager = new DataManager(); switch (commentTable) { case CommentTables.tbl_RequirementComment: RequirementCommentNotificationService.Notify(dataManager.RequirementComment.SelectById(siteId, result.ID)); break; case CommentTables.tbl_RequestComment: RequestCommentNotificationService.Notify(dataManager.RequestComment.SelectById(siteId, result.ID)); break; case CommentTables.tbl_InvoiceComment: InvoiceCommentNotificationService.Notify(dataManager.InvoiceComment.SelectById(siteId, result.ID)); break; } } return(result); }
/// <summary> /// Selects the by id. /// </summary> /// <param name="siteId">The site id.</param> /// <param name="commentId">The comment id.</param> /// <param name="commentTable">The comment table.</param> /// <param name="isPortal">if set to <c>true</c> [is portal].</param> /// <returns></returns> public static ContentComment SelectById(Guid siteId, Guid commentId, CommentTables commentTable, bool isPortal = false) { var result = new ContentComment(); using (var connection = new SqlConnection(Settings.ADONetConnectionString)) { connection.Open(); var query = string.Format("SELECT c.ID, c.SiteID, c.ContentID, c.UserID, c.CreatedAt, contact.UserFullName, dcontact.UserFullName as DestinationUserFullName, c.Comment, c.IsOfficialAnswer, c.IsInternal, c.FileName " + "FROM {0} as c " + "LEFT JOIN tbl_User as u ON c.UserID = u.ID " + "LEFT JOIN tbl_Contact as contact ON u.ContactID = contact.ID " + "LEFT JOIN tbl_User as du ON c.DestinationUserID = du.ID " + "LEFT JOIN tbl_Contact as dcontact ON du.ContactID = dcontact.ID " + "WHERE c.ID = @ID AND c.SiteID = @SiteID AND (@IsInternal IS NULL OR IsInternal = @IsInternal)", commentTable.ToString()); using (var command = new SqlCommand(query, connection)) { command.Parameters.AddWithValue("@ID", commentId); command.Parameters.AddWithValue("@SiteID", siteId); if (isPortal) { command.Parameters.AddWithValue("@IsInternal", false); } else { command.Parameters.AddWithValue("@IsInternal", DBNull.Value); } using (var reader = command.ExecuteReader()) { if (reader.HasRows) { reader.Read(); result.ID = (Guid)reader["ID"]; result.SiteID = (Guid)reader["SiteID"]; result.ContentID = (Guid)reader["ContentID"]; result.UserID = (Guid)reader["UserID"]; result.CreatedAt = (DateTime)reader["CreatedAt"]; result.FormattedDate = ((DateTime)reader["CreatedAt"]).ToString("d MMMM в HH:mm"); result.UserFullName = reader["UserFullName"] != DBNull.Value ? (string)reader["UserFullName"] : null; result.DestinationUserFullName = reader["DestinationUserFullName"] != DBNull.Value ? (string)reader["DestinationUserFullName"] : null; result.Comment = reader["Comment"] != DBNull.Value ? (string)reader["Comment"] : null; result.IsOfficialAnswer = reader["IsOfficialAnswer"] != DBNull.Value && (bool)reader["IsOfficialAnswer"]; result.IsInternal = reader["IsInternal"] != DBNull.Value && (bool)reader["IsInternal"]; result.FileName = reader["FileName"] != DBNull.Value ? (string)reader["FileName"] : null; } } } } var fsp = new FileSystemProvider(); if (!string.IsNullOrEmpty(result.FileName)) { result.VirtualFileName = fsp.GetLink(siteId, EnumHelper.GetEnumDescription(commentTable), result.FileName, FileType.Attachment); } return(result); }