Exemple #1
0
        public ActionResult Comments(string comment, int ArticleId)
        {
            if (!(User.Identity.IsAuthenticated))
            {
                Session["CommentForUserLogin"] = comment;
                Session["articleId"]           = ArticleId;
                return(Redirect("/Home/Login"));
            }
            Session["CommentForUserLogin"] = null;
            var     ArticleRepo = new ArticleRepository(Properties.Settings.Default.ConnectionString);
            var     userrepo    = new UserRepository(Properties.Settings.Default.ConnectionString);
            Comment C           = new Comment
            {
                Comment1    = comment,
                CommentedBy = userrepo.GetUserByEmail(User.Identity.Name).Id,
                ArticleId   = ArticleId,
                Date        = DateTime.Now
            };

            ArticleRepo.AddComment(C);

            return(Redirect($"/Home/Comments?id={ArticleId}"));
        }