Ejemplo n.º 1
0
        public async Task Update(CommentUpdate input)
        {
            var post = input.MapTo <Models.Comment>();

            post.Status = true;
            await _commentRepository.UpdateAsync(post);
        }
Ejemplo n.º 2
0
        private CommentUpdate ToCommentUpdate(object[] r)
        {
            int offset = columns.Count();
            var upd    = new CommentUpdate();

            upd.Comment = ToComment(r);
            if (r[0 + offset] != null)
            {
                upd.CommentedId    = Convert.ToInt32(r[0 + offset]);
                upd.CommentedTitle = Convert.ToString(r[1 + offset]);
                upd.ProjectId      = Convert.ToInt32(r[2 + offset]);
                upd.CommentedType  = EntityType.Milestone;
            }
            else if (r[2 + offset] != null)
            {
                upd.CommentedId    = Convert.ToInt32(r[3 + offset]);
                upd.CommentedTitle = Convert.ToString(r[4 + offset]);
                upd.ProjectId      = Convert.ToInt32(r[5 + offset]);
                upd.CommentedType  = EntityType.Task;
            }
            else
            {
                upd.CommentedId    = Convert.ToInt32(r[6 + offset]);
                upd.CommentedTitle = Convert.ToString(r[7 + offset]);
                upd.ProjectId      = Convert.ToInt32(r[8 + offset]);
                upd.CommentedType  = EntityType.Message;
            }
            return(upd);
        }
Ejemplo n.º 3
0
        public ActionResult Edit(CommentEditModel model)
        {
            if (this.ModelState.IsValid)
            {
                var userId  = this.User.Identity.GetUserId();
                var comment = this.Data.Comments.GetById(model.Id);

                comment.Content = model.Content;

                this.Data.Comments.Update(comment);
                this.Data.SaveChanges();

                if (model.Reason != null)
                {
                    var commentUpdate = new CommentUpdate
                    {
                        AuthorId  = userId,
                        CommentId = comment.Id,
                        Reason    = model.Reason
                    };

                    this.Data.CommentUpdates.Add(commentUpdate);
                    this.Data.SaveChanges();
                }

                var viewModel = Mapper.Map <CommentViewModel>(comment);
                viewModel.IsUpdating = true;

                return(this.PartialView("_CommentDetailPartial", viewModel));
            }

            return(this.JsonError("Content is required"));
        }
Ejemplo n.º 4
0
        public IHttpActionResult UpdateComment([FromUri] int id, [FromBody] CommentUpdate commentUpdate)
        {
            var service = CreateCommentService();

            if (service.UpdateComment(id, commentUpdate))
            {
                return(Ok("Reply Updated"));
            }
            return(InternalServerError());
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> PutComments(long id, CommentDTO commentDTO)
        {
            var CommentUpdate = new CommentUpdate
            {
                CommentId  = id,
                CommentDTO = commentDTO
            };

            return(await CommentUpdate.Excute());
        }
Ejemplo n.º 6
0
        public bool UpdateComment(CommentUpdate model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.Comments.Single(e => e.ID == model.Id);

                entity.Text = model.Text;

                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UpdateCommentRequest"/> class.
 /// </summary>
 /// <param name="name">The filename of the input document.</param>
 /// <param name="commentIndex">The index of the comment.</param>
 /// <param name="comment">Comment data.</param>
 /// <param name="folder">Original document folder.</param>
 /// <param name="storage">Original document storage.</param>
 /// <param name="loadEncoding">Encoding that will be used to load an HTML (or TXT) document if the encoding is not specified in HTML.</param>
 /// <param name="password">Password for opening an encrypted document.</param>
 /// <param name="destFileName">Result path of the document after the operation. If this parameter is omitted then result of the operation will be saved as the source document.</param>
 /// <param name="revisionAuthor">Initials of the author to use for revisions.If you set this parameter and then make some changes to the document programmatically, save the document and later open the document in MS Word you will see these changes as revisions.</param>
 /// <param name="revisionDateTime">The date and time to use for revisions.</param>
 public UpdateCommentRequest(string name, int commentIndex, CommentUpdate comment, string folder = null, string storage = null, string loadEncoding = null, string password = null, string destFileName = null, string revisionAuthor = null, string revisionDateTime = null)
 {
     this.Name             = name;
     this.CommentIndex     = commentIndex;
     this.Comment          = comment;
     this.Folder           = folder;
     this.Storage          = storage;
     this.LoadEncoding     = loadEncoding;
     this.Password         = password;
     this.DestFileName     = destFileName;
     this.RevisionAuthor   = revisionAuthor;
     this.RevisionDateTime = revisionDateTime;
 }
Ejemplo n.º 8
0
        public IActionResult Update([FromBody] CommentUpdate input)
        {
            var a = _commentAppService.GetById(input.Id);

            if (a == null)
            {
                throw new Exception("Không tồn tại comment để update");
            }
            else
            {
                var cmt = _commentAppService.Update(input);
                return(Ok());
            }
        }
Ejemplo n.º 9
0
        public IHttpActionResult Put(CommentUpdate comment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateCommentService();

            if (!service.UpdateComment(comment))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Ejemplo n.º 10
0
        // Put -- Update Comment by Id
        public bool UpdateComment(int id, CommentUpdate comment)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.Comments.Single(e => e.Id == id);

                //Make sure only commenter can update comment
                if (entity.CommenterId != _userId)
                {
                    return(false);
                }

                entity.Text = comment.CommentText;

                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 11
0
        public async Task <Comment> UpdateComment(CommentUpdate commentUpdate)
        {
            var comment = await _shopDbContext.CommentRepository.All
                          .FirstOrDefaultAsync(c => c.CommentId == commentUpdate.CommentId);

            if (comment == null)
            {
                throw new EntityNotFoundException(
                          $"Comment {commentUpdate.CommentId} not found! Can't update the comment");
            }

            _mapper.Map(commentUpdate, comment);
            _shopDbContext.CommentRepository.Update(comment);
            await _shopDbContext.SaveAsync();

            return(_mapper.Map <Comment>(comment));
        }
        public ActionResult PerspectivePost(LatestPerspectivePost latestPerspectivePost, int Id, string TourPermalink, string PerspectivePermalink)
        {
            if (ModelState.IsValid)
            {
                // var commentUpdate = Mapper.Map<CommentUpdate>(latestPerspectivePost.Comment);

                CommentUpdate commentUpdate = new CommentUpdate();
                commentUpdate.Name              = latestPerspectivePost.Name;
                commentUpdate.Email             = latestPerspectivePost.Email;
                commentUpdate.Content           = latestPerspectivePost.Content;
                commentUpdate.PerspectivePostId = Id;
                commentUpdate.IsApproved        = true;
                commentUpdate.PostedOn          = DateTime.Now;

                _commentCommandService.Add(commentUpdate);
                //TempData["CommentSuccess"] = "Comment created successfully.";
                return(RedirectToRoute("perspective-post", new { tourpermalink = TourPermalink, permalink = PerspectivePermalink }));
            }

            var post     = _perspectiveService.FindPerspectivePost(PerspectivePermalink);
            var allTours = _perspectiveService.AllTours().ToList();


            SEOTool SEOTool = new SEOTool();

            if (post != null && post.FirstOrDefault() != null && post.First().SEOTools != null && post.First().SEOTools.Count > 0)
            {
                SEOTool = post.First().SEOTools.First();
            }

            ViewBag.FocusKeyword    = SEOTool.FocusKeyword;
            ViewBag.MetaDescription = SEOTool.MetaDescription;
            ViewBag.SEOTitle        = SEOTool.SEOTitle;

            latestPerspectivePost.FocusKeyword    = SEOTool.FocusKeyword;
            latestPerspectivePost.MetaDescription = SEOTool.MetaDescription;
            latestPerspectivePost.SEOTitle        = SEOTool.SEOTitle;


            latestPerspectivePost.PerspectivePosts      = post.ToList();
            latestPerspectivePost.selectedtourpermalink = TourPermalink;
            latestPerspectivePost.Tours = allTours;

            return(View(latestPerspectivePost));
        }
Ejemplo n.º 13
0
        /// <inheritdoc/>
        protected override async Task <object> CallGitHubApi(DialogContext dc, Octokit.GitHubClient gitHubClient, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (Owner != null && Name != null && Id != null && CommentUpdate != null)
            {
                var ownerValue         = Owner.GetValue(dc.State);
                var nameValue          = Name.GetValue(dc.State);
                var idValue            = Id.GetValue(dc.State);
                var commentUpdateValue = CommentUpdate.GetValue(dc.State);
                return(await gitHubClient.Issue.Comment.Update(ownerValue, nameValue, (Int32)idValue, commentUpdateValue).ConfigureAwait(false));
            }
            if (RepositoryId != null && Id != null && CommentUpdate != null)
            {
                var repositoryIdValue  = RepositoryId.GetValue(dc.State);
                var idValue            = Id.GetValue(dc.State);
                var commentUpdateValue = CommentUpdate.GetValue(dc.State);
                return(await gitHubClient.Issue.Comment.Update((Int64)repositoryIdValue, (Int32)idValue, commentUpdateValue).ConfigureAwait(false));
            }

            throw new ArgumentNullException("Required [id,commentUpdate] arguments missing for GitHubClient.Issue.Comment.Update");
        }
Ejemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UpdateCommentOnlineRequest"/> class.
 /// </summary>
 /// <param name="document">The document.</param>
 /// <param name="commentIndex">The index of the comment.</param>
 /// <param name="comment">Comment data.</param>
 /// <param name="loadEncoding">Encoding that will be used to load an HTML (or TXT) document if the encoding is not specified in HTML.</param>
 /// <param name="password">Password for opening an encrypted document.</param>
 /// <param name="destFileName">Result path of the document after the operation. If this parameter is omitted then result of the operation will be saved as the source document.</param>
 /// <param name="revisionAuthor">Initials of the author to use for revisions.If you set this parameter and then make some changes to the document programmatically, save the document and later open the document in MS Word you will see these changes as revisions.</param>
 /// <param name="revisionDateTime">The date and time to use for revisions.</param>
 public UpdateCommentOnlineRequest(System.IO.Stream document, int commentIndex, CommentUpdate comment, string loadEncoding = null, string password = null, string destFileName = null, string revisionAuthor = null, string revisionDateTime = null)
 {
     this.Document         = document;
     this.CommentIndex     = commentIndex;
     this.Comment          = comment;
     this.LoadEncoding     = loadEncoding;
     this.Password         = password;
     this.DestFileName     = destFileName;
     this.RevisionAuthor   = revisionAuthor;
     this.RevisionDateTime = revisionDateTime;
 }
Ejemplo n.º 15
0
 public CommentUpdateCommand(int commentId, CommentUpdate update, User user) : base(commentId, user)
 {
     Update = update;
 }