Example #1
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());
        }