示例#1
0
        public virtual async Task <RatingDto> CreateAsync(string entityType, string entityId,
                                                          CreateUpdateRatingInput input)
        {
            var userId = CurrentUser.GetId();
            var user   = await CmsUserLookupService.GetByIdAsync(userId);

            var currentUserRating = await RatingRepository.GetCurrentUserRatingAsync(entityType, entityId, userId);

            if (currentUserRating != null)
            {
                currentUserRating.SetStarCount(input.StarCount);
                var updatedRating = await RatingRepository.UpdateAsync(currentUserRating);

                return(ObjectMapper.Map <Rating, RatingDto>(updatedRating));
            }

            var rating = await RatingRepository.InsertAsync(
                new Rating(
                    GuidGenerator.Create(),
                    entityType,
                    entityId,
                    input.StarCount,
                    user.Id,
                    CurrentTenant.Id
                    )
                );

            return(ObjectMapper.Map <Rating, RatingDto>(rating));
        }
示例#2
0
        public virtual async Task <RatingDto> CreateAsync(string entityType, string entityId,
                                                          CreateUpdateRatingInput input)
        {
            var userId = CurrentUser.GetId();
            var user   = await CmsUserLookupService.GetByIdAsync(userId);

            var rating = await RatingManager.SetStarAsync(user, entityType, entityId, input.StarCount);

            return(ObjectMapper.Map <Rating, RatingDto>(rating));
        }
示例#3
0
 public virtual Task <RatingDto> CreateAsync(string entityType, string entityId, CreateUpdateRatingInput input)
 {
     return(RatingPublicAppService.CreateAsync(entityType, entityId, input));
 }