Example #1
0
        public virtual async Task <IViewComponentResult> InvokeAsync(
            string entityType,
            string entityId)
        {
            var result = await ReactionPublicAppService.GetForSelectionAsync(entityType, entityId);

            var viewModel = new ReactionSelectionViewModel
            {
                EntityType = entityType,
                EntityId   = entityId,
                Reactions  = new List <ReactionViewModel>()
            };

            foreach (var reactionDto in result.Items)
            {
                viewModel.Reactions.Add(
                    new ReactionViewModel //TODO: AutoMap
                {
                    Name                    = reactionDto.Reaction.Name,
                    DisplayName             = reactionDto.Reaction.DisplayName,
                    Icon                    = Options.ReactionIcons.GetLocalizedIcon(reactionDto.Reaction.Name),
                    Count                   = reactionDto.Count,
                    IsSelectedByCurrentUser = reactionDto.IsSelectedByCurrentUser
                });
            }

            return(View("~/Pages/CmsKit/Shared/Components/ReactionSelection/Default.cshtml", viewModel));
        }
Example #2
0
        public virtual async Task <IViewComponentResult> InvokeAsync(
            string entityType,
            string entityId)
        {
            var result = await ReactionPublicAppService.GetForSelectionAsync(entityType, entityId);

            var loginUrl =
                $"{AbpMvcUiOptions.LoginUrl}?returnUrl={HttpContext.Request.Path.ToString()}&returnUrlHash=#cms-rating_{entityType}_{entityId}";

            var viewModel = new ReactionSelectionViewModel
            {
                EntityType = entityType,
                EntityId   = entityId,
                Reactions  = new List <ReactionViewModel>(),
                LoginUrl   = loginUrl
            };

            foreach (var reactionDto in result.Items)
            {
                viewModel.Reactions.Add(
                    new ReactionViewModel //TODO: AutoMap
                {
                    Name                    = reactionDto.Reaction.Name,
                    DisplayName             = reactionDto.Reaction.DisplayName,
                    Icon                    = Options.ReactionIcons.GetLocalizedIcon(reactionDto.Reaction.Name),
                    Count                   = reactionDto.Count,
                    IsSelectedByCurrentUser = reactionDto.IsSelectedByCurrentUser
                });
            }

            return(View("~/Pages/CmsKit/Shared/Components/ReactionSelection/Default.cshtml", viewModel));
        }