public ActionResult InsertComment(string Comment) { VwArticlesModel model = new VwArticlesModel(); if (Session["User"] != null) { if (!string.IsNullOrEmpty(Comment)) { user = (Users)Session["User"]; string articleID = RouteData.Values["Id"].ToString(); double dblReplyID = 0; ArticleComments articleComments = new ArticleComments(); SqlConnection LclConn = new SqlConnection(); SqlTransaction SetTransaction = null; bool IsinTransaction = false; if (LclConn.State != ConnectionState.Open) { articleComments.SetConnection = articleComments.OpenConnection(LclConn); SetTransaction = LclConn.BeginTransaction(IsolationLevel.ReadCommitted); IsinTransaction = true; } else { articleComments.SetConnection = LclConn; } articleComments.OptionID = 1; articleComments.ReplyUserId = user.UserId; articleComments.ArticleId = double.Parse(articleID.ToString()); articleComments.ReplyText = Comment; articleComments.InsertedDate = DateTime.Now; bool result = articleComments.CreateArticleComments(ref dblReplyID, SetTransaction); if (IsinTransaction && result) { SetTransaction.Commit(); if (!Session["AskedUserEMail"].ToString().Contains("codeanalyze.com")) { Mail mail = new Mail(); string strLink = "www.codeanalyze.com/VA.aspx?QId=" + articleID.ToString() + "&QT=" + model.ArticleTitle + ""; mail.Body = "<a href=" + strLink + "\\>Click here to view solution to: " + model.ArticleTitle + "</a>"; mail.FromAdd = "*****@*****.**"; mail.Subject = "Code Analyze - Received response for " + model.ArticleTitle; mail.ToAdd = Session["AskedUserEMail"].ToString(); mail.CCAdds = "*****@*****.**"; mail.IsBodyHtml = true; mail.SendMail(); } } else { SetTransaction.Rollback(); } articleComments.CloseConnection(LclConn); ViewBag.ReplyId = dblReplyID; model = SetDefaults(); } else { ViewBag.lblAck = "Please sign in to post your comment."; } } return View("../Articles/Details", model); }