protected virtual NewsViewModel GetViewModel(NewsBase news) { var model = news.Map <NewsViewModel>(); model.HeaderInfo = news.Map <IntranetActivityDetailsHeaderViewModel>(); model.HeaderInfo.Dates = news.PublishDate.ToDateTimeFormat().ToEnumerable(); model.HeaderInfo.Owner = _intranetUserService.Get(news); model.CanEdit = _newsService.CanEdit(news); return(model); }
protected virtual EventPreviewViewModel GetPreviewViewModel(EventBase @event, ActivityLinks links) { var owner = _intranetUserService.Get(@event); return(new EventPreviewViewModel { Id = @event.Id, Title = @event.Title, Dates = @event.StartDate.GetEventDateTimeString(@event.EndDate).ToListOfOne(), Owner = owner, ActivityType = @event.Type, Links = links }); }
protected virtual BulletinViewModel GetViewModel(BulletinBase bulletin, ActivityFeedOptions options) { var model = bulletin.Map <BulletinViewModel>(); model.CanEdit = _bulletinsService.CanEdit(bulletin); model.Links = options.Links; model.IsReadOnly = options.IsReadOnly; model.HeaderInfo = bulletin.Map <IntranetActivityDetailsHeaderViewModel>(); model.HeaderInfo.Dates = bulletin.PublishDate.ToDateTimeFormat().ToEnumerable(); model.HeaderInfo.Owner = _userService.Get(bulletin); model.HeaderInfo.Links = options.Links; return(model); }
protected virtual bool IsOwner(NewsBase newsEntity) { var owner = _intranetUserService.Get(newsEntity); var currentUserId = _intranetUserService.GetCurrentUserId(); return(owner.Id == currentUserId); }
protected virtual bool IsShowIfUnpublish(NewsBase newsEntity) { var owner = _intranetUserService.Get(newsEntity); var currentUserId = _intranetUserService.GetCurrentUserId(); if (owner.Id != currentUserId) { return(IsExpired(newsEntity)); } return(false); }
protected virtual GroupInfoViewModel GetInfoViewModel(Guid groupId) { var group = _groupService.Get(groupId); var groupInfo = group.Map <GroupInfoViewModel>(); var currentUser = _userService.GetCurrentUser(); groupInfo.IsMember = _groupMemberService.IsGroupMember(group.Id, currentUser.Id); groupInfo.CanUnsubscribe = group.CreatorId != currentUser.Id; groupInfo.Creator = _userService.Get(group.CreatorId); groupInfo.MembersCount = _groupMemberService.GetMembersCount(group.Id); groupInfo.CreatorProfileUrl = _profileLinkProvider.GetProfileLink(group.CreatorId); if (group.ImageId.HasValue) { groupInfo.GroupImageUrl = _imageHelper.GetImageWithPreset(Umbraco.TypedMedia(group.ImageId.Value).Url, UmbracoAliases.ImagePresets.GroupImageThumbnail); } return(groupInfo); }
internal UiNotificationMessage GetUiNotificationMessage( Guid receiverId, Enum activityType, Enum notificationType, INotifierDataValue newValue) { var notificationIdentity = new ActivityEventNotifierIdentity(activityType, notificationType, UiNotifierType); var template = _notificationSettingsService.Get <UiNotifierTemplate>(notificationIdentity).Template; var receiver = _intranetUserService.Get(receiverId); var message = _notificationModelMapper.Map(newValue, template, receiver); return(message); }
public virtual IEnumerable <BackofficeGroupViewModel> GetAll(bool showHidden, string field, Direction direction) { var groups = showHidden ? _groupsService.GetAll() : _groupsService.GetAllNotHidden(); var viewModels = groups.Select(s => { var viewModel = s.Map <BackofficeGroupViewModel>(); viewModel.CreatorName = _intranetUserService.Get(s.CreatorId).DisplayedName; viewModel.Link = _groupLinkProvider.GetGroupLink(s.Id); return(viewModel); }); viewModels = Sort(viewModels, field, direction); return(viewModels); }
public virtual ActionResult Overview(Guid?id) { if (!id.HasValue) { return(HttpNotFound()); } var user = _intranetUserService.Get(id.Value); if (user == null) { return(HttpNotFound()); } var result = MapToViewModel(user); return(View(ProfileOverViewPath, result)); }
public virtual ActionResult OwnerEdit(Guid ownerId, string ownerIdPropertyName, IntranetActivityTypeEnum activityType, IActivityCreateLinks links) { var model = new IntranetActivityOwnerEditModel { Owner = _intranetUserService.Get(ownerId), OwnerIdPropertyName = ownerIdPropertyName, Links = links }; var currentUser = _intranetUserService.GetCurrentUser(); model.CanEditOwner = _permissionsService.IsRoleHasPermissions(currentUser.Role, PermissionConstants.CanEditOwner); if (model.CanEditOwner) { model.Users = GetUsersWithAccess(activityType, IntranetActivityActionEnum.Create); } return(PartialView(OwnerEditViewPath, model)); }
protected virtual PagePromotionItemViewModel GetItemViewModel(PagePromotionBase item, IActivityLinks links) { var model = item.Map <PagePromotionItemViewModel>(); model.MediaIds = item.MediaIds; model.Links = links; model.HeaderInfo = item.Map <IntranetActivityItemHeaderViewModel>(); model.HeaderInfo.Owner = _userService.Get(item.CreatorId); model.HeaderInfo.Links = links; model.HeaderInfo.Type = item.Type; model.LightboxGalleryPreviewInfo = new LightboxGalleryPreviewModel { MediaIds = item.MediaIds, DisplayedImagesCount = DisplayedImagesCount, ActivityId = item.Id, ActivityType = item.Type }; return(model); }
protected override Entities.PagePromotion MapInternal(IPublishedContent content) { var pagePromotion = content.Map <Entities.PagePromotion>(); var config = PagePromotionHelper.GetConfig(content); if (config == null) { return(null); } Mapper.Map(config, pagePromotion); pagePromotion.Type = Type; pagePromotion.CreatorId = _userService.Get(pagePromotion.UmbracoCreatorId.Value).Id; var panelValues = _gridHelper.GetValues(content, GridEditorConstants.CommentsPanelAlias, GridEditorConstants.LikesPanelAlias).ToList(); pagePromotion.Commentable = panelValues.Any(panel => panel.alias == GridEditorConstants.CommentsPanelAlias); pagePromotion.Likeable = panelValues.Any(panel => panel.alias == GridEditorConstants.LikesPanelAlias); return(pagePromotion); }
public virtual ActionResult DocumentsTable(Guid groupId, GroupDocumentDocumentField column, Direction direction) { var groupDocumentsList = _groupDocumentsService.GetByGroup(groupId).ToList(); var mediaIdsList = groupDocumentsList.Select(s => s.MediaId).ToList(); var medias = _mediaService.GetByIds(mediaIdsList); var group = _groupService.Get(groupId); var groupMembers = _groupMemberService.GetGroupMemberByGroup(groupId); var currentUser = _intranetUserService.GetCurrentUser(); var docs = medias.Select(s => { var intranetCreator = s.GetValue <Guid?>(IntranetConstants.IntranetCreatorId); var creator = intranetCreator.HasValue ? _intranetUserService.Get(intranetCreator.Value) : _intranetUserService.Get(s.CreatorId); var document = groupDocumentsList.First(f => f.MediaId == s.Id); var url = _umbracoHelper.TypedMedia(s.Id).Url; var model = new GroupDocumentTableRowViewModel { CanDelete = CanDelete(currentUser, group, groupMembers, s), Id = document.Id, CreateDate = s.CreateDate, Name = s.Name, Type = s.GetValue <string>(UmbracoAliases.Media.MediaExtension), CreatorName = creator.DisplayedName, FileUrl = url }; return(model); }); docs = Sort(docs, column, direction); var viewModel = new GroupDocumentsTableViewModel { Documents = docs, GroupId = groupId, Column = column, Direction = direction }; return(PartialView(GroupDocumentsTableViewPath, viewModel)); }