private void GetArticleData(string strArticleId, ref VwArticlesModel model) { ConnManager connManager = new ConnManager(); connManager.OpenConnection(); DataTable dsQuestion = connManager.GetArticle(strArticleId); connManager.DisposeConn(); if (dsQuestion != null) { if (dsQuestion.Rows.Count > 0) { model.ArticleID = long.Parse(dsQuestion.Rows[0]["ArticleId"].ToString()); if (!dsQuestion.Rows[0]["EMail"].ToString().Contains("codeanalyze.com")) { if (!string.IsNullOrEmpty(dsQuestion.Rows[0]["FirstName"].ToString())) { model.AskedUser = "******" + dsQuestion.Rows[0]["FirstName"].ToString() + "<b>"; if (!string.IsNullOrEmpty(dsQuestion.Rows[0]["LastName"].ToString())) { model.AskedUser = model.AskedUser + " <b>" + dsQuestion.Rows[0]["LastName"].ToString() + "<b>"; } } if (!string.IsNullOrEmpty(dsQuestion.Rows[0]["ImageURL"].ToString())) { model.ImageURL = dsQuestion.Rows[0]["ImageURL"].ToString(); } else { model.ImageURL = "~/Images/Person.JPG"; } if (!string.IsNullOrEmpty(dsQuestion.Rows[0]["Details"].ToString())) { model.AskedUserDetails = dsQuestion.Rows[0]["Details"].ToString(); } if (!string.IsNullOrEmpty(dsQuestion.Rows[0]["Stars"].ToString())) { model.Stars = dsQuestion.Rows[0]["Stars"].ToString(); } else { model.Stars = "0"; } } Session["AskedUserEMail"] = dsQuestion.Rows[0]["EMail"].ToString(); //model.ArticleTitle = "<b>" + dsQuestion.Rows[0]["ArticleTitle"].ToString() + "<b>"; model.ArticleTitle = dsQuestion.Rows[0]["ArticleTitle"].ToString(); model.ArticleViews = dsQuestion.Rows[0]["Views"].ToString(); string filepath = string.Empty; if (Request.Url.ToString().Contains("localhost")) filepath = Server.MapPath("/CodeAnalyzeMVC2015/Articles/" + dsQuestion.Rows[0]["WordFile"].ToString()).Replace("\\Details\\Articles", ""); else filepath = Server.MapPath("/Articles/" + dsQuestion.Rows[0]["WordFile"].ToString()).Replace("\\Details\\Articles", ""); using (FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.Read)) { using (TextReader tr = new StreamReader(fs)) { string content = tr.ReadToEnd(); model.ArticleDetails = content; } } //if (dsQuestion.Rows[0]["SourceFile"] != DBNull.Value && !string.IsNullOrEmpty(dsQuestion.Rows[0]["SourceFile"].ToString())) //{ // hfSourceFile.Value = dsQuestion.Rows[0]["SourceFile"].ToString(); // lnkBtnSourceCode.Enabled = true; // lnkBtnSourceCode.ForeColor = Color.Blue; // lnkBtnSourceCode.Text = "Download Source Code"; //} //else //{ // lnkBtnSourceCode.Enabled = false; // lnkBtnSourceCode.ForeColor = Color.Gray; // lnkBtnSourceCode.Text = "No Source Code Uploaded"; //} if (!string.IsNullOrEmpty(dsQuestion.Rows[0]["YouTubURL"].ToString())) { model.iframeVideoURL = "//www.youtube.com/embed?listType=playlist&list=PLr5xM_46LGUtyEyyGilUu3YH5FTNo7SMH"; } model.ThumbsUp = dsQuestion.Rows[0]["ThumbsUp"].ToString(); model.ThumbsDown = dsQuestion.Rows[0]["ThumbsDown"].ToString(); model.HasDemo = Convert.ToInt32(dsQuestion.Rows[0]["HasDemo"].ToString()); if (dsQuestion.Rows[0]["DemoURL"]!=null) { model.DemoURL = dsQuestion.Rows[0]["DemoURL"].ToString(); } } } }