Ejemplo n.º 1
0
        public async Task <ActionResult> UpdateRatingAsync([FromBody] RateModel model)
        {
            var ratingDto = new UpdateRatingDTO()
            {
                FilmId = model.FilmId,
                Rating = model.Rating,
                UserId = HttpContext.GetCurrentUserId()
            };

            try
            {
                await _ratingsService.AddRatingAsync(ratingDto);

                await _FilmsService.UpdateRatingAsync(model.FilmId);

                return(Ok(_ratingsService.GetRating(model.FilmId, ratingDto.UserId)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }