Ejemplo n.º 1
0
        public async Task <IActionResult> Create(CommentValidation comment)
        {
            if (ModelState.IsValid)
            {
                var text = await _mediator.Send(new AddCommentCommand { Text = comment.Text });

                return(View("~/Views/Home/Succeful.cshtml"));
            }

            return(View("~/Views/Home/Index.cshtml"));
        }
Ejemplo n.º 2
0
        public IActionResult CreateComment(string description)
        {
            var comment          = new Domain.Entities.Comment.Comment(description);
            var validationResult = new CommentValidation().Validate(comment);

            if (!validationResult.IsValid)
            {
                return(BadRequest(validationResult.Errors));
            }

            commentAddUseCase.Add(comment);
            return(new OkObjectResult(comment));
        }
Ejemplo n.º 3
0
        public IActionResult UpdateComment(Guid guid, string message)
        {
            if (commentGetByIdUseCase.GetById(guid) == null)
            {
                return(BadRequest());
            }

            var comment = new Domain.Entities.Comment.Comment(guid, message);

            var validationResult = new CommentValidation().Validate(comment);

            if (!validationResult.IsValid)
            {
                return(BadRequest(validationResult.Errors));
            }

            commentUpdateUseCase.Update(comment);
            return(new OkObjectResult(comment));
        }
Ejemplo n.º 4
0
 public void WhenTheyClickSubmit()
 {
     CommentValidation.ValidateComment(comment, out message, out result);
 }