Ejemplo n.º 1
0
        public JsonResult Create(int fileId, string body)
        {
            Comment newComment = new Comment();

            newComment.Body      = body;
            newComment.Creator   = CurrentUser;
            newComment.CreatedOn = DateTime.Now;
            newComment.FileId    = fileId;
            newComment           = serviceComment.Create(newComment);

            var model = new VMComment()
            {
                Body        = newComment.Body,
                CreatedOn   = newComment.CreatedOn,
                Creator     = newComment.Creator,
                CreatorName = newComment.CreatorName,
                DeleteUrl   = Url.Action("Delete", new { id = newComment.Id }),
                Id          = newComment.Id
            };



            var result = new JsonResult()
            {
                Data = model, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };

            return(result);
        }
Ejemplo n.º 2
0
        public JsonResult GetComments(int id = 1)
        {
            var comments = serviceFile.GetFileComments(id);

            List <VMComment> model = new List <VMComment>();

            foreach (var comment in comments)
            {//todo : use automapper
                VMComment vm = new VMComment()
                {
                    Body        = comment.Body,
                    CreatedOn   = comment.CreatedOn,
                    ModifiedOn  = comment.ModifiedOn,
                    CreatorName = comment.CreatorName,
                    Creator     = comment.Creator,
                    Id          = comment.Id,
                    DeleteUrl   = (comment.Creator.Id == CurrentUser.Id ? Url.Action("Delete", "Comment", new { id = comment.Id }) : null)
                };
                model.Add(vm);
            }
            var result = new JsonResult()
            {
                Data = model, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };

            return(result);
        }
Ejemplo n.º 3
0
        public ViewResult Comment(string subject, int id)
        {
            var Crev = new VMComment();

            Crev.Subject  = subject;
            Crev.ReviewID = id;
            Crev.Cmmt     = new Comment();
            return(View(Crev));
        }
Ejemplo n.º 4
0
        public IActionResult Comment(VMComment vmc)
        {
            Review review = (from m in reviewRepo.GetAllReviews()
                             where m.ReviewID == vmc.ReviewID
                             select m).FirstOrDefault <Review>();

            review.Comments.Add(vmc.Cmmt);
            reviewRepo.Update(review);
            return(RedirectToAction("AdminPage", "Admin"));
        }
Ejemplo n.º 5
0
        public JsonResult Edit(VMComment model)
        {
            JsonResult result = new JsonResult();

            if (model == null)
            {
                result.Data = new { message = "No data?" };
                return(result);
            }

            Comment comment = this.serviceComment.GetById(model.Id);

            if (!this.serviceSecurity.HasRight(SecureActivity.CommentEdit, CurrentUser, comment))
            {
                result.Data = new { message = "No, I don't want to :)" };
                return(result);
            }
            comment.Body = model.Body;
            bool bflag = this.serviceComment.Edit(comment);

            result.Data = new { data = bflag };
            return(result);
        }