public RatingViewModel GetLectureNoteRatingForUser(string postId, string username)
        {
            LectureNoteRating rating = _unitOfWork.LectureNoteRatings
                                       .GetByUserAndPost(username, postId);

            if (rating == null)
            {
                return(null);
            }
            else
            {
                RatingViewModel viewRating = _mapper
                                             .Map <LectureNoteRating, RatingViewModel>(rating);
                viewRating.Liked = true;
                return(viewRating);
            }
        }
        public async Task CreateAsync(RatingPutViewModel model)
        {
            var rating = _unitOfWork.LectureNoteRatings.GetByUserAndPost(model.AuthorId, model.PostId);

            if (rating == null)
            {
                var newRating = new LectureNoteRating {
                    LectureNote = _unitOfWork.LectureNotes.Get(model.PostId),
                    User        = _unitOfWork.Users.Get(model.AuthorId),
                    Rating      = model.Rating
                };
                _unitOfWork.LectureNoteRatings.Add(newRating);
            }
            else
            {
                rating.Rating = model.Rating;
                _unitOfWork.LectureNoteRatings.Update(rating);
            }
            await _unitOfWork.SaveAsync();

            await UpdateRatingAsync(model.PostId);
        }