Пример #1
0
        public async Task <ActionResult> ReviewEpisode(int episodeId, EpisodeReviewManipulationDto reviewDto)
        {
            var userId  = _requestContext.UserId;
            var episode = await _reviewService.GetEpisode(episodeId);

            if (episode is Episode)
            {
                var episodeReview = await _reviewService.GetEpisodeReview(episodeId, userId);

                if (episodeReview is EpisodeReview)
                {
                    var reviewUpdateSuccess = await _reviewService.UpdateEpisodeReview(episodeReview, reviewDto);

                    if (reviewUpdateSuccess)
                    {
                        return(NoContent());
                    }
                    return(BadRequest("Unexpected error while saving episode review"));
                }
                else
                {
                    var reviewCreatedSuccess = await _reviewService.CreateEpisodeReview(episodeId, userId, reviewDto);

                    if (reviewCreatedSuccess)
                    {
                        return(NoContent());
                    }
                    return(BadRequest("Unexpected error while saving episode review"));
                }
            }
            else
            {
                return(NotFound());
            }
        }