Ejemplo n.º 1
0
 public void Create(Action action)
 {
     Domain.Entities.Rating rating = GetRating(action);
     rating.Score += _actionTypeRepository.GetActionType(action.ActionTypeId).Scores;
     _ratingRepository.Update(rating);
     // TODO: save action..
 }
Ejemplo n.º 2
0
        public async Task Rate(int id, RatingDto rating)
        {
            var film = await _uow.Repository <Film>().FindOneAsync(new FilmWithRatingsSpecification(id));

            var ratingToInsert = new Domain.Entities.Rating
            {
                UserId      = (int)_currentUserService.UserId,
                RatingValue = rating.Rating,
                CreatedAt   = DateTime.UtcNow
            };

            film.Ratings.Add(ratingToInsert);

            film.Rating = (float)Math.Round(film.Ratings.Select(x => x.RatingValue).Average(), 2);

            await _uow.SaveAsync();
        }