Ejemplo n.º 1
0
        public override ConverterResponseModel MapViewModel(UintraGroupsDocumentsPageModel node, UintraGroupsDocumentsPageViewModel viewModel)
        {
            var settings = _mediaHelper.GetMediaFolderSettings(MediaFolderTypeEnum.GroupsContent);

            viewModel.AllowedMediaExtensions = settings?.AllowedMediaExtensions;

            var id = _context.ParseQueryString("groupId").TryParseGuid();

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

            var group = _groupService.Get(id.Value);

            if (group == null || group.IsHidden)
            {
                return(NotFoundResult());
            }

            viewModel.CanUpload   = _groupDocumentsService.CanUpload(id.Value);
            viewModel.GroupHeader = _groupHelper.GetHeader(id.Value);
            viewModel.GroupId     = id.Value;

            return(OkResult());
        }
Ejemplo n.º 2
0
        public override ConverterResponseModel MapViewModel(UintraGroupsRoomPageModel node, UintraGroupsRoomPageViewModel viewModel)
        {
            var groupId = _context.ParseQueryString("groupId").TryParseGuid();

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

            var group = _groupService.Get(groupId.Value);

            if (group == null || group.IsHidden)
            {
                return(NotFoundResult());
            }

            viewModel.GroupId     = groupId.Value;
            viewModel.GroupInfo   = _groupHelper.GetGroupViewModel(groupId.Value);
            viewModel.GroupHeader = _groupHelper.GetHeader(groupId.Value);

            viewModel.CreateEventsLink = _permissionsService.Check(PermissionResourceTypeEnum.Events, PermissionActionEnum.Create) ?
                                         _feedLinkService.GetCreateLinks(IntranetActivityTypeEnum.Events).Create?.AddGroupId(groupId.Value)
                : null;
            viewModel.CreateNewsLink = _permissionsService.Check(PermissionResourceTypeEnum.News, PermissionActionEnum.Create) ?
                                       _feedLinkService.GetCreateLinks(IntranetActivityTypeEnum.News).Create.AddGroupId(groupId.Value)
                : null;

            var socialCreateModel = _nodeModelService.AsEnumerable().OfType <SocialCreatePageModel>().First();

            viewModel.SocialCreateModel = _nodeModelService.GetViewModel <SocialCreatePageViewModel>(socialCreateModel);

            return(OkResult());
        }
Ejemplo n.º 3
0
        public override ConverterResponseModel MapViewModel(UintraGroupsEditPageModel node, UintraGroupsEditPageViewModel viewModel)
        {
            var groupId = _context.ParseQueryString("groupId").TryParseGuid();

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

            var group = _groupService.Get(groupId.Value);

            if (group == null || group.IsHidden)
            {
                return(NotFoundResult());
            }

            if (!_groupService.CanEdit(groupId.Value))
            {
                return(ForbiddenResult());
            }

            var settings = _mediaHelper.GetMediaFolderSettings(MediaFolderTypeEnum.GroupsContent);

            viewModel.AllowedMediaExtensions = settings?.AllowedMediaExtensions;
            viewModel.Info        = _groupHelper.GetInfoViewModel(groupId.Value);
            viewModel.GroupHeader = _groupHelper.GetHeader(groupId.Value);
            viewModel.GroupId     = groupId.Value;

            return(OkResult());
        }
Ejemplo n.º 4
0
        public override ConverterResponseModel MapViewModel(ProfilePageModel node, ProfilePageViewModel viewModel)
        {
            var id = _uBaselineRequestContext.ParseQueryString("id").TryParseGuid();

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

            var member = _memberService.Get(id.Value);

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

            var currentMemberId = _memberService.GetCurrentMemberId();

            if (member.Id == currentMemberId)
            {
                viewModel.EditProfileLink = _intranetUserContentProvider.GetEditPage().Url.ToLinkModel();
            }

            var mediaSettings = _mediaHelper.GetMediaFolderSettings(MediaFolderTypeEnum.MembersContent, true);

            viewModel.Profile       = member.Map <ProfileViewModel>();
            viewModel.Profile.Photo = _imageHelper.GetImageWithResize(member.Photo, PresetStrategies.ForMemberProfile.ThumbnailPreset);
            viewModel.Profile.AllowedMediaExtensions = mediaSettings.AllowedMediaExtensions;
            viewModel.Tags = _userTagService.Get(member.Id);

            return(OkResult());
        }
        public void Map(HomePageModel node, HomePageViewModel viewModel)
        {
            var groupId = _context.ParseQueryString("groupId").TryParseGuid();

            viewModel.CreateEventsLink =
                _permissionsService.Check(PermissionResourceTypeEnum.Events, PermissionActionEnum.Create)
                    ? _feedLinkService.GetCreateLinks(IntranetActivityTypeEnum.Events).Create
                    : null;
            viewModel.CreateNewsLink =
                _permissionsService.Check(PermissionResourceTypeEnum.News, PermissionActionEnum.Create)
                    ? _feedLinkService.GetCreateLinks(IntranetActivityTypeEnum.News).Create
                    : null;

            if (node.UserListPage.Value.HasValue)
            {
                var userListPage = _nodeModelService.Get(node.UserListPage.Value.Value);
                viewModel.UserListPage = userListPage.Url.ToLinkModel();
            }


            if (groupId.HasValue)
            {
                viewModel.CreateNewsLink   = viewModel.CreateNewsLink?.AddGroupId(groupId.Value);
                viewModel.CreateEventsLink = viewModel.CreateEventsLink?.AddGroupId(groupId.Value);
            }

            var socialCreateModel = _nodeModelService.AsEnumerable().OfType <SocialCreatePageModel>().First();

            viewModel.SocialCreateModel = _nodeModelService.GetViewModel <SocialCreatePageViewModel>(socialCreateModel);
        }
Ejemplo n.º 6
0
        public void Map(ArticlePageModel node, ArticlePageViewModel viewModel)
        {
            var groupId = _context.ParseQueryString("groupId").TryParseGuid();

            viewModel.Breadcrumbs   = _breadcrumbService.GetBreadcrumbs();
            viewModel.GroupId       = groupId;
            viewModel.SubNavigation = _subNavigationModelBuilder.GetMenu();
        }
        public void Map(CentralFeedPanelModel node, CentralFeedPanelViewModel viewModel)
        {
            var command = GetPermissionCommand();

            viewModel.Tabs            = _activityTabsBuilder.Build(command);
            viewModel.ItemsPerRequest = node.ItemsPerRequest.Value == 0 ? 10 : node.ItemsPerRequest.Value;
            viewModel.GroupId         = _context.ParseQueryString("groupId").TryParseGuid();
        }
Ejemplo n.º 8
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());
        }
        public override ConverterResponseModel MapViewModel(UintraNewsEditPageModel node, UintraNewsEditPageViewModel viewModel)
        {
            var id = _context.ParseQueryString("id").TryParseGuid();

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

            var news = _newsService.Get(id.Value);

            if (news == null || news.IsHidden)
            {
                return(NotFoundResult());
            }

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

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

            viewModel.Details                = GetDetails(news);
            viewModel.Links                  = _feedLinkService.GetLinks(news.Id);
            viewModel.CanEditOwner           = _permissionsService.Check(PermissionResourceTypeEnum.News, PermissionActionEnum.EditOwner);
            viewModel.AllowedMediaExtensions = _newsService.GetMediaSettings().AllowedMediaExtensions;
            viewModel.PinAllowed             = _permissionsService.Check(PermissionResourceTypeEnum.News, PermissionActionEnum.CanPin);

            if (viewModel.CanEditOwner)
            {
                viewModel.Members = GetUsersWithAccess(new PermissionSettingIdentity(PermissionActionEnum.Create, PermissionResourceTypeEnum.News));
            }

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

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

            return(OkResult());
        }
        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());
        }
Ejemplo n.º 11
0
        public override ConverterResponseModel MapViewModel(UintraGroupsMembersPageModel node, UintraGroupsMembersPageViewModel viewModel)
        {
            var groupId = _context.ParseQueryString("groupId").TryParseGuid();

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

            var group = _groupService.Get(groupId.Value);

            if (group == null || group.IsHidden)
            {
                return(NotFoundResult());
            }

            viewModel.GroupHeader = _groupHelper.GetHeader(groupId.Value);

            return(OkResult());
        }
Ejemplo n.º 12
0
        public override ConverterResponseModel MapViewModel(SocialCreatePageModel node, SocialCreatePageViewModel viewModel)
        {
            var groupId = _context.ParseQueryString("groupId").TryParseGuid();

            if (groupId.HasValue)
            {
                var group = _groupService.Get(groupId.Value);
                if (group == null || group.IsHidden)
                {
                    return(NotFoundResult());
                }
            }

            if (!HasPermission(groupId))
            {
                return(ForbiddenResult());
            }
            viewModel.Data        = GetData(groupId);
            viewModel.GroupHeader = groupId.HasValue ? _groupHelper.GetHeader(groupId.Value) : null;

            return(OkResult());
        }
        public override ConverterResponseModel MapViewModel(LikesPanelModel node, LikesPanelViewModel viewModel)
        {
            var activityId = _context.ParseQueryString("id").TryParseGuid();

            var activityType = activityId.HasValue
                ? _activityTypeHelper.GetActivityType(activityId.Value)
                : IntranetActivityTypeEnum.ContentPage;

            var id = activityType.Equals(IntranetActivityTypeEnum.ContentPage)
                ? _requestContext.Node?.Key
                : activityId;

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

            var groupId = _groupActivityService.GetGroupId(id.Value);

            var currentMember = _intranetMemberService.GetCurrentMember();

            viewModel.IsGroupMember = !groupId.HasValue || currentMember.GroupIds.Contains(groupId.Value);

            if (!viewModel.IsGroupMember)
            {
                return(ForbiddenResult());
            }

            var likes = _likesService.GetLikeModels(id.Value).ToArray();

            viewModel.Likes              = likes;
            viewModel.EntityId           = id.Value;
            viewModel.LikedByCurrentUser = likes.Any(el => el.UserId == currentMember.Id);
            viewModel.ActivityType       = activityType;

            return(OkResult());
        }
Ejemplo n.º 14
0
        public override ConverterResponseModel MapViewModel(CommentsPanelModel node, CommentsPanelViewModel viewModel)
        {
            var activityId = _context.ParseQueryString("id").TryParseGuid();

            var activityType = activityId.HasValue
                ? _activityTypeHelper.GetActivityType(activityId.Value)
                : IntranetEntityTypeEnum.ContentPage;

            var id = activityType.Equals(IntranetEntityTypeEnum.ContentPage)
                ? _requestContext.Node?.Key
                : activityId;

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

            var groupId = _groupActivityService.GetGroupId(id.Value);

            var currentMember = _intranetMemberService.GetCurrentMember();

            viewModel.IsGroupMember = !groupId.HasValue || currentMember.GroupIds.Contains(groupId.Value);

            if (!viewModel.IsGroupMember)
            {
                return(ForbiddenResult());
            }

            var comments = _commentsService.GetMany(id.Value);

            viewModel.Comments     = _commentsHelper.GetCommentViews(comments);
            viewModel.EntityId     = id.Value;
            viewModel.CommentsType = activityType;

            return(OkResult());
        }