Пример #1
0
        public async Task <IActionResult> EditReview(ReviewEditViewModel editModel)
        {
            if (ModelState.IsValid)
            {
                var response = await _reviewData.EditReview(editModel);

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

                return(RedirectToAction("Review", new { id = editModel.Id }));
            }

            ModelState.AddModelError("Error", "Not all fields were filled in correctly.");
            return(View());
        }
Пример #2
0
        public async Task <IActionResult> EditReview([FromBody] ReviewEdit editModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            try
            {
                if (!await _reviewData.EditReview(editModel))
                {
                    return(NotFound());
                }

                return(NoContent());
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }