public async Task AddRatingAsync(UpdateRatingDTO ratingDto) { var ratingEntity = new Rating() { Value = ratingDto.Rating, User = _unitOfWork.Users.Get(ratingDto.UserId), Film = _unitOfWork.Films.Get(ratingDto.FilmId), }; _unitOfWork.Ratings.Add(ratingEntity); await _unitOfWork.SaveAsync(); }
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)); } }
public ActionResult Put([FromBody] UpdateRatingDTO updateRatingDTO) { _business.UpdateRatingAttractionById(updateRatingDTO.Id, updateRatingDTO.Status); return(Ok(true)); }