public ActionResult Create(int idPost, string text)
        {
            comment c1 = new comment();
            post    p1 = p.FindById(idPost);

            c1.post        = p1;
            c1.text        = text;
            c1.commentDate = DateTime.Now;
            c1.user        = CurrentUser.get();
            c.Create(c1);
            c.Commit();
            return(RedirectToAction("DetailPost", "Post", new { id = c1.idPost }));
        }
Пример #2
0
        public ActionResult CreateComment(string con, int id)
        {
            Comment comment = new Comment()
            {
                Contenu       = con,
                PublicationId = id
            };

            MyCommentService.Add(comment);
            MyCommentService.Commit();



            return(Json(comment, JsonRequestBehavior.AllowGet));
        }
        public ActionResult AddSubComment(SubCommentsVM subComment, int ComID)
        {
            SubComment subCommentEntity = null;
            // int userId = (int)Session["UserID"];
            string      currentUserId = User.Identity.GetUserId();
            int         userId        = 1;
            List <User> GetUsers      = sp.GetUsers();

            var user    = GetUsers.FirstOrDefault(u => u.Id == currentUserId);
            var comment = sp.GetComments().FirstOrDefault(p => p.ComID == ComID);

            if (subComment != null)
            {
                subCommentEntity = new SubComment
                {
                    CommentMsg    = subComment.CommentMsg,
                    CommentedDate = DateTime.Now
                                    //subComment.CommentedDate,
                };


                if (user != null && comment != null)
                {
                    comment.SubComments.Add(subCommentEntity);
                    user.SubComments.Add(subCommentEntity);
                    sc.Commit();
                    su.Commit();
                    sp.Commit();
                    //  dbContext.SaveChanges();
                    //result = true;
                }
            }

            return(RedirectToAction("GetSubComments", "Comments", new { ComID = ComID }));
        }
Пример #4
0
        public ActionResult CreateComment(int PostId, string ContenuCom)
        {
            Comment comment = new Comment()
            {
                ContenuCom      = ContenuCom,
                PostId          = PostId,
                ParticipantId   = Int32.Parse(User.Identity.GetUserId()),
                DateCom         = DateTime.Now,
                ParticipantName = User.Identity.GetUserName(),
            };

            CommentService.Add(comment);
            CommentService.Commit();



            return(Json(comment, JsonRequestBehavior.AllowGet));
        }
Пример #5
0
        // GET: Comment/Delete/5
        public ActionResult Delete(int id)
        {
            CommentService commserv = new CommentService();
            comment        c        = new comment();

            c = commserv.GetById(id);
            commserv.Delete(c);
            commserv.Commit();

            return(RedirectToAction("report"));
        }
Пример #6
0
        public ActionResult Create(int id, CommentViewModel cvm)
        {
            Comment b = new Comment();

            b.BlogId  = id;
            b.Contenu = cvm.Contenu;
            b.NbrLike = 0;
            commentService.Add(b);
            commentService.Commit();

            return(View());
        }
Пример #7
0
        public ActionResult Create(CommentViewModel pvm, PostViewModel id)
        {
            var c = Ps.GetAll();

            foreach (var item in c)
            {
                PostViewModel Cvm = new PostViewModel();
                Cvm.postId    = item.postId;
                Cvm.posttitre = item.posttitre;
                Cvm.content   = item.content;

                /*Cvm.categoryId = item.categoryId;
                 * Cvm.description = item.description;
                 * Cvm.plan = item.plan;
                 * Cvm.goals = item.goals;
                 * Cvm.state = (WebApplication1.Models.stat)stat.To_Do;*/
            }

            // ViewBag.cat = new SelectList(c, "projectId", "projectname");

            Comment p = new Comment();

            p.commentId = pvm.commentId;
            p.postId    = id.postId;
            // p.deadline = pvm.deadline;
            p.content = pvm.content;



            //p.state = (Domain.Entities.state)stat.To_Do;
            //p.ListTask = (ICollection<Domain.Entities.Task>)pvm.ListTask;
            Ts.Add(p);
            Ts.Commit();

            try
            {
                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Пример #8
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
                CommentService commserv = new CommentService();
                comment        c        = new comment();
                c = commserv.GetById(id);
                commserv.Delete(c);
                commserv.Commit();


                return(RedirectToAction("report"));
            }
            catch
            {
                return(View());
            }
        }
Пример #9
0
        public ActionResult Create(int id, CommentViewModel cvm)
        {
            User        u           = new User();
            UserService userService = new UserService();

            Comment c = new Comment();

            c.CommentId       = cvm.CommentId;
            c.DateCom         = DateTime.Now;
            c.ParticipantId   = int.Parse(User.Identity.GetUserId());;
            c.PostId          = id;
            c.ParticipantName = us.GetUserById(c.ParticipantId).FirstName + " " + us.GetUserById(c.ParticipantId).LastName;
            c.ContenuCom      = cvm.ContenuCom;

            repo.Add(c);
            repo.Commit();

            return(RedirectToAction("../Post/Details", new { id = c.PostId }));
        }