コード例 #1
0
        public async Task <IActionResult> PatchEdit(EditCommentModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Error(ModelState.Values.SelectMany(v => v.Errors).FirstOrDefault().ErrorMessage));
            }

            var EditedComment = await Context.NeedComment.Include(comment => comment.Need).FirstOrDefaultAsync(x =>
                                                                                                               x.Id == model.Id &&
                                                                                                               !x.IsRemoved &&
                                                                                                               x.UserId == Guid.Parse(User.Identity.GetUserId()));

            if (EditedComment != null)
            {
                if (EditedComment.Need.Stage != 3)
                {
                    return(Error("Burada yorum düzenlenemez"));
                }

                if (EditedComment.Comment != model.Comment)
                {
                    EditedComment.Comment = model.Comment.RemoveLessGreaterSigns();
                    await Context.SaveChangesAsync();

                    return(Succes("Yorum içeriğiniz düzenlendi"));
                }

                return(Error("Aynı içerik ile düzenlemeye çalıştınız"));
            }
            return(Error("Düzenlemeye çalıştığınız yorum yok", null, null, 404));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(long id, [FromBody] EditCommentModel model)
        {
            if (false == ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await mediator.Send(
                new EditCommentCommand(User, id, model.Content, model.IsPublic),
                HttpContext.RequestAborted
                );

            if (false == result.IsSuccess())
            {
                return(BadRequest(result.Exceptions));
            }

            await commandBus.SendAsync(new CommentUpdatedIntegrationCommand
            {
                Id = Guid.NewGuid(),
                //StoryId = result.Data.Id,
                Sent = dateTimeProvider.Now
            });

            logger.StoryUpdated(result.Data.Id);

            return(Ok(mapper.Map <StoryModel>(result.Data)));
        }
コード例 #3
0
        //// GET: Forum/Create
        //public ActionResult Create()
        //{
        //    ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "Name");
        //    ViewBag.SuggestionId = new SelectList(db.Suggestions, "SuggestionId", "UserId");
        //    ViewBag.TopicId = new SelectList(db.Topics, "TopicId", "Name");
        //    return View();
        //}

        //// POST: Forum/Create
        //// To protect from overposting attacks, please enable the specific properties you want to bind to, for
        //// more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public async Task<ActionResult> Create([Bind(Include = "ForumId,SuggestionId,DepartmentId,TopicId,DateAdded,LastUpdated,IsActive,UpVotes,DownVotes")] Forum forum)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        db.Forums.Add(forum);
        //        await db.SaveChangesAsync();
        //        return RedirectToAction("Index");
        //    }

        //    ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "Name", forum.DepartmentId);
        //    ViewBag.SuggestionId = new SelectList(db.Suggestions, "SuggestionId", "UserId", forum.SuggestionId);
        //    ViewBag.TopicId = new SelectList(db.Topics, "TopicId", "Name", forum.TopicId);
        //    return View(forum);
        //}

        //// GET: Forum/Edit/5
        //public async Task<ActionResult> Edit(int? id)
        //{
        //    if (id == null)
        //    {
        //        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        //    }
        //    Forum forum = await db.Forums.FindAsync(id);
        //    if (forum == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "Name", forum.DepartmentId);
        //    ViewBag.SuggestionId = new SelectList(db.Suggestions, "SuggestionId", "UserId", forum.SuggestionId);
        //    ViewBag.TopicId = new SelectList(db.Topics, "TopicId", "Name", forum.TopicId);
        //    return View(forum);
        //}

        //// POST: Forum/Edit/5
        //// To protect from overposting attacks, please enable the specific properties you want to bind to, for
        //// more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public async Task<ActionResult> Edit([Bind(Include = "ForumId,SuggestionId,DepartmentId,TopicId,DateAdded,LastUpdated,IsActive,UpVotes,DownVotes")] Forum forum)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        db.Entry(forum).State = EntityState.Modified;
        //        await db.SaveChangesAsync();
        //        return RedirectToAction("Index");
        //    }
        //    ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "Name", forum.DepartmentId);
        //    ViewBag.SuggestionId = new SelectList(db.Suggestions, "SuggestionId", "UserId", forum.SuggestionId);
        //    ViewBag.TopicId = new SelectList(db.Topics, "TopicId", "Name", forum.TopicId);
        //    return View(forum);
        //}

        // GET: ForumMessages/Edit/5

        public async Task <ActionResult> EditMessage(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ForumMessage forumMessage = await db.ForumMessages.FindAsync(id);

            if (forumMessage == null)
            {
                return(HttpNotFound());
            }

            var editComment = new EditCommentModel
            {
                ForumId        = forumMessage.ForumId,
                ForumMessageId = forumMessage.ForumMessageId,
                Message        = forumMessage.Message
            };

            //ViewBag.ForumId = new SelectList(db.Forums, "ForumId", "ForumId", forumMessage.ForumId);
            //ViewBag.UserId = new SelectList(db.Users, "Id", "FirstName", forumMessage.UserId);
            return(View(editComment));
        }
コード例 #4
0
        public IActionResult Edit([Bind(nameof(EditCommentModel.Id),
                                        nameof(EditCommentModel.Email),
                                        nameof(EditCommentModel.Name),
                                        nameof(EditCommentModel.IsAprove),
                                        nameof(EditCommentModel.BlogcomposeId),
                                        nameof(EditCommentModel.Message)
                                        )]
                                  EditCommentModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    model.Edit();
                    model.Response = new ResponseModel("Approve successful.", ResponseType.Success);

                    //logger code
                    _logger.LogInformation("Comment Approve Successfully");

                    return(RedirectToAction("Index"));
                }

                catch (Exception ex)
                {
                    model.Response = new ResponseModel("Comment Approve failed.", ResponseType.Failure);
                    // error logger code
                    _logger.LogError($"Comment Approve 'Failed'. Excption is : {ex.Message}");
                }
            }
            return(RedirectToAction("Index"));
        }
コード例 #5
0
        public IActionResult Edit(int id)
        {
            var model = new EditCommentModel();

            model.Load(id);

            return(View(model));
        }
コード例 #6
0
 public ActionResult Edit(EditCommentModel model)
 {
     var response = _commandBus.Send <EditComment, EditCommentResponse>(new EditComment
     {
         EditedBy = _userContext.CurrentUser.Id
                    DateEdited = Common.CurrentTime(),
         CommentId             = model.CommentId,
         Body = model.Body
     });
コード例 #7
0
 public ActionResult EditComment(EditCommentModel model)
 {
     using (BlogContext context = new BlogContext())
     {
         Comment comment = context.Comments.SingleOrDefault(c => c.CommentId == model.CommentID);
         comment.Title   = model.Title;
         comment.Content = model.Content;
         context.SaveChanges();
         return(RedirectToAction("ViewPost", "Post", new { comment.Post.PostId }));
         // return RedirectToAction("ViewSingleComment", new { @CommentID = comment.CommentId });
     }
 }
コード例 #8
0
ファイル: CommentController.cs プロジェクト: wria7/IrisCms
 public virtual ActionResult Edit(EditCommentModel commentModel)
 {
     _commentService.Update(new Comment {
         Id = commentModel.Id, Body = commentModel.Body.ToSafeHtml()
     });
     _uow.SaveChanges();
     return(PartialView(MVC.Admin.Shared.Views._Alert, new Alert
     {
         Message = "دیدگاه مورد نظر با موفقیت به روز رسانی شد",
         Mode = AlertMode.Success
     }));
 }
コード例 #9
0
 public IActionResult Edit([FromBody] EditCommentModel model)
 {
     try
     {
         var comment = _commentService.Edit(model, int.Parse(User.Identity.Name));
         CommentResourceModel commentResource = _mapper.Map <CommentResourceModel>(comment);
         return(Ok(commentResource));
     }
     catch (AppException ex)
     {
         return(BadRequest(new { message = ex.Message }));
     }
 }
コード例 #10
0
        public async Task <IActionResult> EditComment([FromBody] EditCommentModel editCommentModel)
        {
            var response = await _commentService.EditComment(editCommentModel, Convert.ToInt32(Request.Cookies["userId"]));

            if (response.Code <= HttpStatusCode.PermanentRedirect)
            {
                return(Json(response.Data));
            }
            else
            {
                return(BadRequest());
            }
        }
コード例 #11
0
        public ActionResult GetWorkOrdersPictures(EditCommentModel model)
        {
            var pictures = _repository.SearchFor <SageImageWorkOrder>(x => x.WorkOrder == model.WorkOrder).SingleOrDefault();

            if (pictures == null)
            {
                return(Error("Edit picture comments failed", $"GetWorkOrdersPictures method SageImageWorkOrder==false."));
            }
            pictures.Images.Find(x => x.Id == model.Id && !x.IsDeleted).Description = model.Comment;
            _repository.Update(pictures);
            _hub.UpdateWorkOrderPicture(pictures);
            return(Success());
        }
コード例 #12
0
        public async Task <IActionResult> Edit(int id, EditCommentModel model)
        {
            var result = await this.CommentService.Edit(id, model.Content);

            if (result.Success)
            {
                return(this.Redirect(this.GenerateCommentLink(result.Data.TopicID, result.Data.ID)));
            }
            else
            {
                return(this.Notice(result.ErrorMessage));
            }
        }
コード例 #13
0
ファイル: CommentController.cs プロジェクト: IdokkeI/News-App
        public async Task <ActionResult> EditComment(EditCommentModel model)
        {
            var username = User.GetUserName();
            var comment  = await commentService.EditComment(
                model.CommentId,
                username,
                model.Text);

            if (comment)
            {
                return(Ok());
            }
            return(BadRequest());
        }
コード例 #14
0
ファイル: CommentController.cs プロジェクト: csf-dev/agiil
        public ActionResult Edit(IIdentity <Comment> id)
        {
            var comment = commentReader.Value.Read(id);

            if (ReferenceEquals(comment, null))
            {
                return(HttpNotFound());
            }

            var model = new EditCommentModel {
                Comment       = mapper.Map <CommentDto>(comment),
                Response      = TempData.TryGet <Models.Tickets.EditCommentResponse>(EditCommentResponseKey),
                Specification = TempData.TryGet <EditCommentSpecification>(EditCommentSpecKey),
            };

            return(View(model));
        }
コード例 #15
0
        public async Task <ActionResult> EditMessage(EditCommentModel model)
        {
            if (ModelState.IsValid)
            {
                var forumMessage = await db.ForumMessages.FindAsync(model.ForumMessageId);

                forumMessage.Message     = model.Message;
                forumMessage.LastUpdated = DateTime.Now;

                db.Entry(forumMessage).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Messages", new { id = model.ForumId }));
            }
            //ViewBag.ForumId = new SelectList(db.Forums, "ForumId", "ForumId", model.ForumId);
            //ViewBag.UserId = new SelectList(db.Users, "Id", "FirstName", forumMessage.UserId);
            return(View(model));
        }
コード例 #16
0
        public ActionResult EditCommentForm(Comment comment)
        {
            var controller = DependencyResolver.Current.GetService <AuthorizeController>();

            controller.ControllerContext = new ControllerContext(this.Request.RequestContext, controller);
            var us = controller.CommentAuthorize(comment.CommentId);


            if (us == true)
            {
                EditCommentModel model = new EditCommentModel()
                {
                    CommentID = comment.CommentId, Content = comment.Content, Title = comment.Title
                };
                return(View(model));
            }
            else
            {
                return(View("~/Views/Authorize/NotAuthorizeView.cshtml"));
            }
        }
コード例 #17
0
        public async Task <IBaseResponse <List <CommentModel> > > EditComment(EditCommentModel editCommentModel, int userId)
        {
            var editedComment = await _applicationContext.Comments.FindAsync(editCommentModel.CommentId);

            if (editedComment != null)
            {
                editedComment.Text = editCommentModel.Text;
                await _applicationContext.SaveChangesAsync();
            }

            var commentList = await _applicationContext.Comments.Where(com => com.LectureId == editedComment.LectureId).ToListAsync();

            var comments = new List <CommentModel>();

            comments = await CommonMethods.GetCommentList(commentList, comments, _applicationContext, _mapper, userId);

            return(new BaseResponse <List <CommentModel> >
            {
                Code = editedComment != null ? HttpStatusCode.OK : HttpStatusCode.BadRequest,
                Data = comments
            });
        }
コード例 #18
0
        public Comment Edit(EditCommentModel model, int userId)
        {
            Comment comment = _context.Comments.Find(model.Id);

            if (comment != null)
            {
                if (comment.UserId == userId)
                {
                    comment.Content  = model.Content;
                    comment.EditedAt = DateTime.UtcNow;
                    _context.SaveChanges();
                    return(comment);
                }
                else
                {
                    throw new AppException("You don't have permission to edit this comment");
                }
            }
            else
            {
                throw new AppException("Comment not found");
            }
        }
コード例 #19
0
ファイル: CommentController.cs プロジェクト: linwenda/Funzone
    public async Task <IActionResult> EditAsync([FromRoute] Guid id, [FromBody] EditCommentModel model)
    {
        await _mediator.Send(new EditCommentCommand(id, model.Text));

        return(Ok());
    }
コード例 #20
0
        public async Task <IActionResult> EditComment(string commentId, EditCommentModel editCommentModel)
        {
            await this.commentService.EditComment(commentId, editCommentModel.SanitizedText);

            return(this.Redirect($"/Forum/All"));
        }
コード例 #21
0
ファイル: CommentsController.cs プロジェクト: skimur/skimur
        public ActionResult Edit(EditCommentModel model)
        {
            var response = _commandBus.Send<EditComment, EditCommentResponse>(new EditComment
            {
                EditedBy = _userContext.CurrentUser.Id
                DateEdited = Common.CurrentTime(),
                CommentId = model.CommentId,
                Body = model.Body
            });

            if (!string.IsNullOrEmpty(response.Error))
                return CommonJsonResult(response.Error);

            var html = RenderView("_CommentBody", new CommentNode(_commentWrapper.Wrap(model.CommentId, _userContext.CurrentUser)));

            return Json(new
            {
                success = true,
                commentId = model.CommentId,
                // we don't render the whole comment, just the body.
                // this is because we want to leave the children in-tact on the ui
                html
            });
        }