public async Task <IActionResult> CreateComment(int id, [FromBody] CommentCreate createModel)
        {
            if (createModel == null || !ModelState.IsValid)
            {
                return(BadRequest());
            }

            var review = await _reviewData.GetReview(id);

            if (review == null)
            {
                return(NotFound());
            }

            try
            {
                await _reviewData.CreateComment(createModel);

                return(NoContent());
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Beispiel #2
0
        public async Task <IActionResult> CreateComment(CommentCreate createModel)
        {
            if (!ModelState.IsValid)
            {
                return(null);
            }

            var response = await _reviewData.CreateComment(createModel);

            if (!response.IsSuccessful)
            {
                return(View("Error", new ErrorViewModel(response.ErrorMessage,
                                                        response.ErrorException.ToString())));
            }

            return(RedirectToAction("Review", new { id = createModel.ReviewId }));
        }