Esempio n. 1
0
        public ActionResult AddComment(Comment comment, String sTitle)
        {
            System.Diagnostics.Debug.WriteLine("sesss" + Session["LoggedIn"]);
            if (Session["LoggedIn"] == null || Session["LoggedIn"].Equals(false) || Session["LoggedIn"].ToString().Length == 0)
            {
                TempData["commentAdded"] = "Please Log in.";
                return(View(comment));
            }
            comment.Writer    = UserPersistence.GetUser(Session["userId"].ToString());
            comment.CommentId = CommentPersistence.getMaxId() + 1;
            System.Diagnostics.Debug.WriteLine("***" + sTitle);
            comment.Service = ServicePersistence.GetService(sTitle);
            bool?acceptible = false;

            acceptible = CommentManager.AddNewComment(comment);
            if ((acceptible != null))
            {
                if (acceptible == true)
                {
                    TempData["commentAdded"] = "Comment is added successfully.";
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    TempData["commenteAdded"] = "Comment could not be added.";
                    return(View(comment));
                }
            }
            else
            {
                TempData["commentAdded"] = "Comment could not be added.";
                return(View(comment));
            }
        }
Esempio n. 2
0
        public ActionResult AddComment(Comment comment, String sTitle)
        {
            System.Diagnostics.Debug.WriteLine("sesss" + Session["LoggedIn"]);
            if (Session["LoggedIn"] == null || Session["LoggedIn"].Equals(false) || Session["LoggedIn"].ToString().Length == 0)
            {
                TempData["commentAdded"] = "Please Log in.";
                return(RedirectToAction("ServiceDetail", "Service", new { title = sTitle }));
            }
            comment.Writer    = UserPersistence.GetUser(Session["userId"].ToString());
            comment.CommentId = CommentPersistence.getMaxId() + 1;
            System.Diagnostics.Debug.WriteLine("***" + sTitle);
            comment.Service = ServicePersistence.GetService(sTitle);
            bool?acceptible = false;

            string t  = comment.Content.Replace("<", "&lt");
            string t1 = t.Replace(">", "&gt");
            string t2 = t1.Replace("(", "&#40");
            string t3 = t2.Replace(")", "&#41");
            string t4 = t3.Replace("&", "&#38");

            t4 = t4.Replace("'", "");
            string tfinal = t4.Replace("|", "&#124");

            comment.Content = tfinal;

            acceptible = CommentManager.AddNewComment(comment);
            if ((acceptible != null))
            {
                if (acceptible == true)
                {
                    TempData["commentAdded"] = "Comment is added successfully.";
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    TempData["commentAdded"] = "Comment could not be added.";
                    return(RedirectToAction("ServiceDetail", "Service", new { title = sTitle }));
                }
            }
            else
            {
                TempData["commentAdded"] = "Comment could not be added.";
                return(RedirectToAction("ServiceDetail", "Service", new { title = sTitle }));
            }
        }