Exemplo n.º 1
0
        public async Task <IActionResult> Post(int gameId, [FromBody] BLComment comment)
        {
            if (gameId <= 0 || comment == null || comment.Body.Length == 0 || comment.GameId < 0 ||
                comment.Name.Length == 0)
            {
                return(BadRequest("Wrong arguments for model creation"));
            }

            comment.GameId = gameId;
            await _commentService.AddAsync(comment);

            return(Created("/api/comments/" + gameId, comment));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> CreateComment([FromQuery] CommentAddDto commentAddDto)
        {
            commentAddDto.CommentDate = DateTime.Now;
            await _commentService.AddAsync(_mapper.Map <Comment>(commentAddDto));

            return(Created("", commentAddDto));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> AddComment(CommentAddDto model)
        {
            model.PostedTime = DateTime.Now;
            await _commentService.AddAsync(_mapper.Map <Comment>(model));

            return(RedirectToAction("Detail", new { id = model.BlogId }));
        }
        //[ValidModel]
        public async Task <IActionResult> CommentAdd(CommentAddDto commentAddDto)
        {
            commentAddDto.PostedTime = DateTime.Now;
            await _commentService.AddAsync(_mapper.Map <Comment>(commentAddDto));

            return(Created("", commentAddDto));
        }
        public async Task <JsonResult> Add(CommentAddDto commentAddDto)
        {
            if (ModelState.IsValid)
            {
                var result = await _commentService.AddAsync(commentAddDto);

                if (result.ResultStatus == ResultStatus.Success)
                {
                    var commentAddAjaxViewModel = JsonSerializer.Serialize(new CommentAddAjaxViewModel
                    {
                        CommentDto        = result.Data,
                        CommentAddPartial = await this.RenderViewToStringAsync("_CommentAddPartial", commentAddDto)
                    }, new JsonSerializerOptions
                    {
                        ReferenceHandler = ReferenceHandler.Preserve
                    });
                    return(Json(commentAddAjaxViewModel));
                }
                ModelState.AddModelError("", result.Message);
            }
            var commentAddAjaxErrorModel = JsonSerializer.Serialize(new CommentAddAjaxViewModel
            {
                CommentAddDto     = commentAddDto,
                CommentAddPartial = await this.RenderViewToStringAsync("_CommentAddPartial", commentAddDto)
            });

            return(Json(commentAddAjaxErrorModel));
        }
Exemplo n.º 6
0
        public async Task AddAsync_Null_ThrowRutrackerException()
        {
            // Act & Assert
            var exception = await Assert.ThrowsAsync <RutrackerException>(async() =>
                                                                          await _commentService.AddAsync(null));

            Assert.Equal(ExceptionEventTypes.InvalidParameters, exception.ExceptionEventType);
        }
Exemplo n.º 7
0
 public async Task <IActionResult> Comment(ViewModel.InformationViewModel vmodel)
 {
     if (ModelState.IsValid)
     {
         await FCommentServices.AddAsync(vmodel.Comment);
     }
     return(View());
 }
Exemplo n.º 8
0
 public async Task <IActionResult> AddComment(CommentAddDto model)
 {
     if (ModelState.IsValid)
     {
         await _commentService.AddAsync(model.Adapt <Comment>());
     }
     return(RedirectToAction("Detail", "Home", new { id = model.ArticleId }));
 }
 public async Task<IActionResult> AddComment([Bind("Content,Id,UserId,PostId")] CommentDto comment)
 {
     if (ModelState.IsValid)
     {
         await commentService.AddAsync(comment);
         return ViewComponent("CommentSection", new { postId = comment.PostId });
     }
     return BadRequest();
 }
Exemplo n.º 10
0
        public async Task <CommentView> Post(CommentCreateView model)
        {
            var comment = _mapper.Map <Comment>(model);

            comment.UserId = User.GetUserId();

            var result = await _commentService.AddAsync(comment);

            return(_mapper.Map <CommentView>(result));
        }
Exemplo n.º 11
0
      public async Task <IActionResult> AddComment(Comment comment)
      {
          int userId = Convert.ToInt32(User.FindFirst(ClaimTypes.NameIdentifier)?.Value);

          comment.UserId      = userId;
          comment.CommentDate = DateTime.Now;
          var newComment = await _commentService.AddAsync(comment);

          return(Created(string.Empty, newComment));
      }
Exemplo n.º 12
0
        public async Task <JsonResult> AddComment([FromBody] Comment comment)
        {
            Comment newModel = await _commentService.AddAsync(new Comment
            {
                Content    = comment.Content,
                CreateDate = DateTime.Now,
                bookId     = (int)comment.bookId
            });

            return(Json(newModel));
        }
Exemplo n.º 13
0
        public async Task <ActionResult <CommentDto> > AddComment(AddComment comment)
        {
            var userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;

            if (userId is null)
            {
                return(BadRequest(new ErrorDto("No user data!")));
            }

            return(await _commentService.AddAsync(comment.Text, userId, comment.EntryId));
        }
Exemplo n.º 14
0
        public async Task <IHttpActionResult> Post([FromBody] CommentView comment)
        {
            if (comment == null)
            {
                return(BadRequest());
            }

            var commentInfo = _mapper.Map <CommentView, CommentInfo>(comment);
            var result      = await _commentService.AddAsync(commentInfo);

            return(result.IsError ? BadRequest(result.Message) : (IHttpActionResult)Ok(result.Data));
        }
Exemplo n.º 15
0
        public async Task <IActionResult> AddAsync([FromBody] AddCommentRequest addCommentRequest)
        {
            var response = await _commentService.AddAsync(addCommentRequest);

            if (response.Success)
            {
                return(Ok());
            }
            else
            {
                return(BadRequest(response.Message));
            }
        }
Exemplo n.º 16
0
        public async Task <IActionResult> AddComment(CommentAddDto commentAddDto)
        {
            if (commentAddDto.AuthorName.Contains("Admin") || commentAddDto.AuthorName.Contains("admin"))
            {
                commentAddDto.AuthorName = "ÇakalKarlos";
            }

            commentAddDto.PostedTime = DateTime.Now;
            commentAddDto.IsApproved = false;
            await _commentService.AddAsync(_mapper.Map <Comment>(commentAddDto));

            return(Created("", commentAddDto));
        }
Exemplo n.º 17
0
        public async Task <IActionResult> AddComment(AddCommentModel model)
        {
            var comment = new Comment()
            {
                Date      = DateTime.Now,
                EventId   = model.EventId,
                Message   = model.Message,
                Pseudonym = model.Pseudonym
            };
            await _commentService.AddAsync(comment);

            await _commentService.SaveChangesAsync();

            return(Redirect($"/Event/{model.EventId}"));
        }
Exemplo n.º 18
0
        public async Task <IActionResult> Detail(string description, int sharingId)
        {
            var currentUser = await GetCurrentUserAsync();

            Comment comment = new Comment
            {
                Description          = description,
                CommentDate          = DateTime.Now,
                NumberOfLikes        = 0,
                LastModificationDate = DateTime.Now,
                UserId    = currentUser.Id,
                SharingId = sharingId,
            };
            await _commentService.AddAsync(comment);

            return(RedirectToAction("Detail", sharingId));
        }
Exemplo n.º 19
0
        public async Task SendComment(Guid newsId, string content)
        {
            var comment = new CommentViewModel
            {
                NewsId   = newsId,
                AuthorId = Context.User.GetUserId(),
                Content  = content
            };

            comment = await commentService.AddAsync(comment);

            var isAuthorized = await authorizationService.AuthorizeAsync(Context.User, "RequireRole");

            var isInRoles = isAuthorized.Succeeded;

            await Clients.Caller.ClearComment();

            await Clients.Group(newsId.ToString()).ReceiveComment(comment, isInRoles);
        }
Exemplo n.º 20
0
        public async Task <IHttpActionResult> Create([FromBody, CustomizeValidator(RuleSet = "AddComment, default")] CommentWeb commentWeb)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                var    sub       = (User as ClaimsPrincipal).FindFirst("sub");
                string subString = sub.Value;
                var    user      = (await Uservice.GetByIdAsync(subString));
                if (user.IsSuccess == true)
                {
                    var userId = user.Data;

                    var commentlogic = mapper.Map <CommentWeb, CommentLogic>(commentWeb);
                    commentlogic.User = userId;
                    var result = await service.AddAsync(commentlogic);

                    if (result.IsSuccess == true)
                    {
                        await bus.SendAsync("Podcasts", $"Added Comment to {commentlogic.Course.Name} by {userId.Name}");

                        return(Ok(commentlogic));
                    }
                    else
                    {
                        return(BadRequest(result.Message));
                    }
                }
                else
                {
                    return(Unauthorized());
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Exemplo n.º 21
0
        public async Task <IActionResult> Post([FromBody] CommentViewModel viewModel, [FromServices] IAspNetUser user)
        {
            ResultModel <CommentViewModel> resultModel = new ResultModel <CommentViewModel>();

            if (viewModel.SubordinateID.isEmpty())
            {
                resultModel.Message = "发表失败!";
                return(Ok(resultModel));
            }
            var comment = this.mapper.Map <Comment>(viewModel);

            comment.Commentator = user.Name;
            comment.CommentTime = DateTime.Now;
            var r = await commentService.AddAsync(comment);

            if (r > 0)
            {
                resultModel.Message = "发表成功!";
                resultModel.Data    = this.mapper.Map <CommentViewModel>(comment);
            }
            return(Ok(resultModel));
        }
Exemplo n.º 22
0
        public async Task <IActionResult> Add(CommentAddDto commentAddDto)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new JResult
                {
                    Status = Status.BadRequest,
                    Message = "Eksik veya hatalı kayıtlar mevcut!"
                }));
            }


            var comment = _mapper.Map <Comment>(commentAddDto);

            await _commentService.AddAsync(comment);

            try
            {
                var userInDb = await _userManager.FindByNameAsync("admin");

                var body = new StringBuilder();
                body.AppendLine($"Ad Soyad:  {commentAddDto.Name}");
                body.AppendLine($"<br />");
                body.AppendLine($"Email: {commentAddDto.EmailAdress}");
                body.AppendLine($"<br />");
                body.AppendLine($"Mesaj : {commentAddDto.Content}");
                SendMail.MailSender($"BerendBebe - Yeni Yorum", body.ToString(), userInDb.Email);
            }
            catch (Exception)
            {
            }

            return(Json(new JResult
            {
                Status = Status.Ok,
                Message = "Yorumunuz alınmıştır. Değerlendikten sonra onaylanacaktır."
            }));
        }
Exemplo n.º 23
0
        public async Task <IActionResult> Create(CommentCreateDto commentDto)
        {
            var comment = ObjectMapper.Mapper.Map <CommentDto>(commentDto);

            return(ActionResultInstance(await _commentService.AddAsync(comment)));
        }
        public async Task <IActionResult> AddNewComment([FromBody] CommentPostDto commentPostDto)
        {
            var commentResp = await commentService.AddAsync(commentPostDto);

            return(CreatedAtAction("GetClient", new { id = commentResp.ID }, mapper.Map <CommentResponseDto>(commentResp)));
        }
Exemplo n.º 25
0
        public async Task <IActionResult> PostComment(int articleId, PostCommentModel model)
        {
            await _commentService.AddAsync(articleId, User.GetId(), model.Body);

            return(Ok(model));
        }
Exemplo n.º 26
0
        public async Task <IActionResult> CreateComment([FromBody] CommentCreateDto model)
        {
            var result = await _commentService.AddAsync(model);

            return(CreatedAtAction(nameof(GetCommentById), new { id = result.Id }, null));
        }
Exemplo n.º 27
0
        public CommentListViewModel(IODataClient oDataClient,
                                    ICommentValidator commentValidator,
                                    ISanaapAppTranslateService translateService,
                                    IUserDialogs userDialogs,
                                    IEventAggregator eventAggregator,
                                    ICommentService commentService,
                                    IPageDialogService pageDialogService)
        {
            _oDataClient    = oDataClient;
            _userDialogs    = userDialogs;
            _commentService = commentService;

            CommentTypes = EnumHelper <CommentType> .GetDisplayValues(CommentType.Complaint);

            SelectedCommentType = CommentTypes[1];

            CreateComment = new BitDelegateCommand(async() =>
            {
                submitCancellationTokenSource?.Cancel();
                submitCancellationTokenSource = new CancellationTokenSource();

                using (userDialogs.Loading(ConstantStrings.Loading, cancelText: ConstantStrings.Loading_Cancel, onCancel: submitCancellationTokenSource.Cancel))
                {
                    Comment.CommentType = (CommentType)CommentTypes.IndexOf(SelectedCommentType);

                    if (!commentValidator.IsValid(Comment, out string errorMessage))
                    {
                        await pageDialogService.DisplayAlertAsync(string.Empty, translateService.Translate(errorMessage), ConstantStrings.Ok);
                        return;
                    }

                    Comment = await commentService.AddAsync(Comment);

                    await pageDialogService.DisplayAlertAsync(string.Empty, ConstantStrings.SuccessfulProcess, ConstantStrings.Ok);

                    Comment = new CommentDto();

                    eventAggregator.GetEvent <OpenCreateCommentPopupEvent>().Publish(new OpenCreateCommentPopupEvent());

                    await loadComments();
                }
            });

            ShowComment = new BitDelegateCommand <CommentItemSource>(async(comment) =>
            {
                if (string.IsNullOrEmpty(comment.Answer))
                {
                    comment.Answer = ConstantStrings.ResponseNotFoundFromSupport;
                }

                await NavigationService.NavigateAsync(nameof(CommentAnswerPopupView), new NavigationParameters
                {
                    { nameof(Comment), comment }
                });
            });

            OpenCreatePopup = new BitDelegateCommand(async() =>
            {
                eventAggregator.GetEvent <OpenCreateCommentPopupEvent>().Publish(new OpenCreateCommentPopupEvent());
            });
        }
Exemplo n.º 28
0
        public async Task <ActionResult <CommentViewModel> > CreateCommentAsync([FromBody] CreateCommentRequest request)
        {
            var createdEntity = await _commentService.AddAsync(request);

            return(Created(string.Format(CreateEntityPattern, RoutePattern, createdEntity.Id), createdEntity));
        }
 public async Task <CommentDTO> AddPostAsync([FromBody] CommentDTO comment)
 {
     return(await service.AddAsync(comment));
 }
 public async Task HandlerAsync(CreateComment command)
 {
     await _commentService.AddAsync(command.Content, command.UserId, command.PostId);
 }