Ejemplo n.º 1
0
        public async Task <IActionResult> Create([FromRoute] AddRatingRequest request)
        {
            var rating = await _ratingService.CreateRatingFromRequest(request);

            var success = await _ratingService.AddRatingAsync(rating);

            if (!success)
            {
                return(NotFound());
            }

            var baseUrl     = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}";
            var locationUri = baseUrl + "/" + ApiRoutes.Ratings.Get.Replace("{Id}", rating.RatingGuid.ToString());

            var response = await _ratingService.CreateRatingResponse(rating);

            return(Created(locationUri, response));
        }