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(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.º 3
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.º 4
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(EventDetailsPageModel node,
                                                            EventDetailsPageViewModel viewModel)
        {
            var idStr = HttpUtility.ParseQueryString(_baselineRequestContext.NodeRequestParams.NodeUrl.Query)
                        .TryGetQueryValue <string>("id");

            if (!Guid.TryParse(idStr, out var id))
            {
                return(NotFoundResult());
            }

            var @event = _eventsService.Get(id);

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

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

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

            var member = _memberService.GetCurrentMember();

            viewModel.Details       = GetDetails(@event);
            viewModel.Tags          = _userTagService.Get(id);
            viewModel.CanEdit       = _eventsService.CanEdit(id);
            viewModel.IsGroupMember = [email protected] || member.GroupIds.Contains(@event.GroupId.Value);

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

            if (Guid.TryParse(groupIdStr, out var groupId) && @event.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.º 8
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.º 9
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());
        }