public override ConverterResponseModel MapViewModel(SocialDetailsPageModel node, SocialDetailsPageViewModel viewModel)
        {
            var id = _context.ParseQueryString("id").TryParseGuid();

            if (!id.HasValue)
            {
                return(NotFoundResult());
            }

            var social = _socialService.Get(id.Value);

            if (social == null)
            {
                return(NotFoundResult());
            }

            if (social.GroupId.HasValue)
            {
                var group = _groupService.Get(social.GroupId.Value);
                if (group != null && group.IsHidden)
                {
                    return(NotFoundResult());
                }
            }

            if (!_permissionsService.Check(PermissionResourceTypeEnum.Social, PermissionActionEnum.View))
            {
                return(ForbiddenResult());
            }

            var member = _memberService.GetCurrentMember();

            viewModel.Details       = GetViewModel(social);
            viewModel.Tags          = _userTagService.Get(id.Value);
            viewModel.CanEdit       = _socialService.CanEdit(id.Value);
            viewModel.IsGroupMember = !social.GroupId.HasValue || member.GroupIds.Contains(social.GroupId.Value);

            var groupIdStr = HttpContext.Current.Request["groupId"];

            if (Guid.TryParse(groupIdStr, out var groupId) && social.GroupId == groupId)
            {
                viewModel.GroupHeader = _groupHelper.GetHeader(groupId);
            }

            return(OkResult());
        }
Beispiel #2
0
        public override ConverterResponseModel MapViewModel(SocialEditPageModel node, SocialEditPageViewModel viewModel)
        {
            var id = _context.ParseQueryString("id").TryParseGuid();

            if (!id.HasValue)
            {
                return(NotFoundResult());
            }

            var social = _socialService.Get(id.Value);

            if (social == null)
            {
                return(NotFoundResult());
            }

            if (social.GroupId.HasValue)
            {
                var group = _groupService.Get(social.GroupId.Value);
                if (group != null && group.IsHidden)
                {
                    return(NotFoundResult());
                }
            }

            if (!_socialService.CanEdit(id.Value))
            {
                return(ForbiddenResult());
            }

            viewModel.CanDelete            = _socialService.CanDelete(id.Value);
            viewModel.OwnerId              = social.OwnerId;
            viewModel.Id                   = social.Id;
            viewModel.Description          = social.Description;
            viewModel.Name                 = _localizationModelService["Social.Edit"];
            viewModel.Tags                 = _userTagService.Get(id.Value);
            viewModel.LightboxPreviewModel = _lightboxHelper.GetGalleryPreviewModel(social.MediaIds, PresetStrategies.ForActivityDetails);
            viewModel.AvailableTags        = _userTagProvider.GetAll();
            viewModel.Links                = _feedLinkService.GetLinks(social.Id);

            var mediaSettings = _socialService.GetMediaSettings();

            viewModel.AllowedMediaExtensions = mediaSettings.AllowedMediaExtensions;

            var groupId = HttpContext.Current.Request["groupId"].TryParseGuid();

            if (groupId.HasValue && social.GroupId == groupId.Value)
            {
                viewModel.GroupHeader = _groupHelper.GetHeader(groupId.Value);
            }

            return(OkResult());
        }
Beispiel #3
0
        protected async Task <SocialExtendedViewModel> GetSocialViewModelAsync(Guid id)
        {
            var social = _socialService.Get(id);

            var viewModel = social.Map <SocialViewModel>();

            viewModel.Media = MediaHelper.GetMediaUrls(social.MediaIds);

            viewModel.LightboxPreviewModel = _lightboxHelper.GetGalleryPreviewModel(social.MediaIds, PresetStrategies.ForActivityDetails);
            viewModel.CanEdit = _socialService.CanEdit(social);
            viewModel.Links   = await _feedLinkService.GetLinksAsync(id);

            viewModel.IsReadOnly       = false;
            viewModel.HeaderInfo       = social.Map <IntranetActivityDetailsHeaderViewModel>();
            viewModel.HeaderInfo.Dates = social.PublishDate.ToDateTimeFormat().ToEnumerable();
            viewModel.HeaderInfo.Owner = _memberService.Get(social).ToViewModel();
            viewModel.HeaderInfo.Links = await _feedLinkService.GetLinksAsync(id);

            var extendedModel = viewModel.Map <SocialExtendedViewModel>();

            return(extendedModel);
        }