Example #1
0
        public async Task <IActionResult> ConfirmCreateComment(CreateCommentViewModel comment)
        {
            var commentDto = Mapper.Map <CommentDto>(comment);

            commentDto.User = User.CreateUserDto();

            await _commentManager.CreateComment(commentDto);

            return(RedirectToAction("Index", "Home"));
        }
Example #2
0
 public IActionResult Post([FromBody] Comment comment)
 {
     try
     {
         _commentManager.CreateComment(comment);
         return(Ok());
     }
     catch (ArgumentException ex)
     {
         return(BadRequest(ex));
     }
 }
        public CreateCommentDlgViewModel(IParticlesManager particlesManager, IBlockManager blockManager,
            ICommentManager commentManager, IEventAggregator eventAggregator)
        {
            _particlesManager = particlesManager;
            _blockManager = blockManager;
            _commentManager = commentManager;
            _eventAggregator = eventAggregator;
            AddParticleVm = new AddParticleViewViewModel(particlesManager);

            SelectBlockCommand = new DelegateCommand(() =>
            {
                var dlg = new SelectTagDlg(typeof (Guidable));
                var res = dlg.ShowDialog();
                if (res.HasValue && res.Value && dlg.Id.HasValue)
                {
                    _myGuidable = _blockManager.GetGuidableById(dlg.Id.Value);
                    OkCommand.RaiseCanExecuteChanged();
                    if (_myGuidable is Material)
                        GuidableCaption = (_myGuidable as Material).Name;
                    else if (_myGuidable is Block)
                        GuidableCaption = (_myGuidable as Block).Caption;
                }
            });

            OkCommand = new DelegateCommand<Window>((wnd) =>
            {
                var comment = _commentManager.CreateComment(Caption, _myGuidable);

                if (AddParticleVm.AddParticle)
                    if (AddParticleVm.UseNewParticle)
                    {
                        var particle = _particlesManager.CreateParticle(AddParticleVm.NewParticle.Material,
                            AddParticleVm.NewParticle.Begin, AddParticleVm.NewParticle.End);
                        _blockManager.AddParticleToBlock(comment, particle);
                        ParticleId = particle.Id;
                    }
                    else if (AddParticleVm.UseExistParticle && AddParticleVm.ExistParticle.HasValue)
                    {
                        var particle = _particlesManager.GetParticleById(AddParticleVm.ExistParticle.Value);
                        _blockManager.AddParticleToBlock(comment, particle);
                        ParticleId = particle.Id;
                    }

                _eventAggregator.GetEvent<BlockAddedEvent>().Publish(comment.Id);
                wnd.DialogResult = true;
                wnd.Close();
            }, wnd => !String.IsNullOrWhiteSpace(Caption) && _myGuidable != null);
        }
        public async Task <ResponseModel <GenericModel> > ReplyGuide(CreateCommentViewModel viewModel)
        {
            Guid userId        = JWTHelper.SeriallzeUserId(_httpContext);
            var  responseModel = new ResponseModel <GenericModel>();

            if (Guid.TryParse(viewModel.GuideId, out Guid guideId) && userId != Guid.Empty)
            {
                Guid commentId = await _commentManger.CreateComment(userId, guideId, viewModel.Content);

                await _commentReviewManager.CreateCommentReview(commentId);

                responseModel.Code = StateCode.Sucess;
                responseModel.Data = new GenericModel
                {
                    IsSucess = true
                };
            }
            return(responseModel);
        }