public virtual PartialViewResult Index(ISubscribable subscribe, Guid activityId) { var userId = _intranetUserService.GetCurrentUserId(); var subscriber = subscribe.Subscribers.SingleOrDefault(s => s.UserId == userId); return(Index(activityId, subscriber, subscribe.Type)); }
public virtual PartialViewResult Edit(CommentEditModel model) { var editCommentId = FullContext.Value.EntityId.Value; var commentsTarget = FullContext.GetCommentsTarget(); var targetEntityId = commentsTarget.EntityId.Value; if (!ModelState.IsValid) { return(OverView(editCommentId)); } var comment = _commentsService.Get(editCommentId); if (!_commentsService.CanEdit(comment, _intranetUserService.GetCurrentUserId())) { return(OverView(editCommentId)); } var editDto = MapToEditDto(model, editCommentId); var command = new EditCommentCommand(FullContext, editDto); _commandPublisher.Publish(command); switch (commentsTarget.Type.ToInt()) { case int type when ContextExtensions.HasFlagScalar(type, ContextType.Activity | ContextType.PagePromotion): var activityCommentsInfo = GetActivityComments(targetEntityId); return(OverView(activityCommentsInfo)); default: return(OverView(comment.ActivityId)); } }
public virtual PartialViewResult AddLike() { var likeTarget = FullContext.Value; var targetEntityId = likeTarget.EntityId.Value; var command = new AddLikeCommand(FullContext, _intranetUserService.GetCurrentUserId()); _commandPublisher.Publish(command); switch (likeTarget.Type.ToInt()) { case (int)Comment: return(Likes(_likesService.GetLikeModels(targetEntityId), targetEntityId)); case (int)ContentPage: return(Likes(_likesService.GetLikeModels(targetEntityId), targetEntityId, showTitle: true)); case int type when HasFlagScalar(type, Activity | PagePromotion): var activityLikeInfo = GetActivityLikes(targetEntityId); return(Likes(activityLikeInfo.Likes, activityLikeInfo.Id, activityLikeInfo.IsReadOnly, showTitle: HasFlagScalar(type, PagePromotion))); default: throw new IndexOutOfRangeException(); } }
public ActionResult Create() { var createGroupModel = new GroupCreateModel(); var mediaSettings = _mediaHelper.GetMediaFolderSettings(MediaFolderTypeEnum.GroupsContent, true); createGroupModel.MediaRootId = mediaSettings.MediaRootId; createGroupModel.CreatorId = _userService.GetCurrentUserId(); createGroupModel.AllowedMediaExtensions = mediaSettings.AllowedMediaExtensions; return(PartialView(CreateViewPath, createGroupModel)); }
public virtual ActionResult Documents(Guid groupId) { var groupMembers = _groupMemberService.GetGroupMemberByGroup(groupId); var currentUserId = _intranetUserService.GetCurrentUserId(); var model = new GroupDocumentsViewModel { GroupId = groupId, CanUploadFiles = groupMembers.Any(s => s.MemberId == currentUserId) }; return(PartialView(DocumentsViewPath, model)); }
protected virtual EventBase MapToEvent(EventBackofficeCreateModel model) { var @event = model.Map <EventBase>(); @event.CreatorId = _intranetUserService.GetCurrentUserId(); return(@event); }
protected virtual bool IsOwner(NewsBase newsEntity) { var owner = _intranetUserService.Get(newsEntity); var currentUserId = _intranetUserService.GetCurrentUserId(); return(owner.Id == currentUserId); }
protected virtual EventCreateModel GetCreateModel(IActivityCreateLinks links) { var mediaSettings = _eventsService.GetMediaSettings(); var model = new EventCreateModel { StartDate = DateTime.UtcNow, EndDate = DateTime.UtcNow.AddHours(8), PublishDate = DateTime.UtcNow, OwnerId = _intranetUserService.GetCurrentUserId(), ActivityType = _activityTypeProvider[ActivityTypeId], Links = links, MediaRootId = mediaSettings.MediaRootId }; return(model); }
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 NewsBase MapToNews(NewsCreateModel createModel) { var news = createModel.Map <NewsBase>(); news.MediaIds = news.MediaIds.Concat(_mediaHelper.CreateMedia(createModel)); news.PublishDate = createModel.PublishDate.ToUniversalTime(); news.UnpublishDate = createModel.UnpublishDate?.ToUniversalTime(); news.EndPinDate = createModel.EndPinDate?.ToUniversalTime(); news.CreatorId = _intranetUserService.GetCurrentUserId(); return(news); }
public virtual NewsBackofficeViewModel Create(NewsBackofficeCreateModel createModel) { var creatingNews = createModel.Map <NewsBase>(); creatingNews.CreatorId = _intranetUserService.GetCurrentUserId(); var newsId = _newsService.Create(creatingNews); var createdNews = _newsService.Get(newsId); var result = createdNews.Map <NewsBackofficeViewModel>(); return(result); }
public virtual BulletinsBackofficeViewModel Create(BulletinsBackofficeCreateModel createModel) { var creatingBulletin = createModel.Map <BulletinBase>(); creatingBulletin.CreatorId = creatingBulletin.OwnerId = _intranetUserService.GetCurrentUserId(); var bulletinId = _bulletinsService.Create(creatingBulletin); var createdBulletin = _bulletinsService.Get(bulletinId); var result = createdBulletin.Map <BulletinsBackofficeViewModel>(); return(result); }
public virtual ActionResult Index(int page = 1) { var take = page * ItemsPerPage; var notifications = _uiNotifierService.GetMany(_intranetUserService.GetCurrentUserId(), take, out var totalCount).ToList(); var notNotifiedNotifications = notifications.Where(el => !el.IsNotified).ToList(); if (notNotifiedNotifications.Count > 0) { _uiNotifierService.Notify(notNotifiedNotifications); } var notificationsViewModels = notifications.Select(MapNotificationToViewModel).ToList(); var result = new NotificationListViewModel { Notifications = notificationsViewModels, BlockScrolling = totalCount <= take }; return(PartialView(ListViewPath, result)); }
protected virtual BulletinBase MapToBulletin(BulletinCreateModel model) { var bulletin = model.Map <BulletinBase>(); bulletin.PublishDate = DateTime.UtcNow; bulletin.CreatorId = bulletin.OwnerId = _userService.GetCurrentUserId(); if (model.NewMedia.HasValue()) { bulletin.MediaIds = _mediaHelper.CreateMedia(model); } return(bulletin); }
public IMedia CreateMedia(TempFile file, int rootMediaId, Guid?userId = null) { userId = userId ?? _intranetUserService.GetCurrentUserId(); var mediaTypeAlias = GetMediaTypeAlias(file); var media = _mediaService.CreateMedia(file.FileName, rootMediaId, mediaTypeAlias); if (_videoConverter.NeedConvert(mediaTypeAlias, file.FileName)) { media.SetValue(IntranetConstants.IntranetCreatorId, userId.ToString()); media.SetValue(UmbracoAliases.Video.ThumbnailUrlPropertyAlias, _videoHelper.CreateConvertingThumbnail()); media.SetValue(UmbracoAliases.Video.ConvertInProcessPropertyAlias, true); _mediaService.Save(media); Task.Run(() => { _videoConverter.Convert(new MediaConvertModel() { File = file, MediaId = media.Id }); }); return(media); } var stream = new MemoryStream(file.FileBytes); if (_imageHelper.IsFileImage(file.FileBytes)) { var fileStream = new MemoryStream(file.FileBytes, 0, file.FileBytes.Length, true, true); stream = _imageHelper.NormalizeOrientation(fileStream, Path.GetExtension(file.FileName)); } media.SetValue(IntranetConstants.IntranetCreatorId, userId.ToString()); media.SetValue(UmbracoFilePropertyAlias, Path.GetFileName(file.FileName), stream); stream.Close(); if (mediaTypeAlias == VideoTypeAlias) { SaveVideoAdditionProperties(media); } _mediaService.Save(media); return(media); }
private void ResolveMentions(string text, EventBase @event) { var mentionIds = _mentionService.GetMentions(text).ToList(); if (mentionIds.Any()) { var links = _activityLinkService.GetLinks(@event.Id); _mentionService.ProcessMention(new MentionModel() { MentionedSourceId = @event.Id, CreatorId = _intranetUserService.GetCurrentUserId(), MentionedUserIds = mentionIds, Title = @event.Title.StripHtml(), Url = links.Details, ActivityType = IntranetActivityTypeEnum.Events }); } }
private void ResolveMentions(string text, BulletinBase bulletin) { var mentionIds = _mentionService.GetMentions(text).ToList(); if (mentionIds.Any()) { var links = _activityLinkService.GetLinks(bulletin.Id); const int maxTitleLength = 100; _mentionService.ProcessMention(new MentionModel() { MentionedSourceId = bulletin.Id, CreatorId = _intranetUserService.GetCurrentUserId(), MentionedUserIds = mentionIds, Title = bulletin.Description.StripHtml().TrimByWordEnd(maxTitleLength), Url = links.Details, ActivityType = IntranetActivityTypeEnum.Bulletins }); } }
private void ResolveMentions(string text, CommentModel comment) { var mentionIds = _mentionService.GetMentions(text).ToList(); if (mentionIds.Any()) { var content = Umbraco.TypedContent(comment.ActivityId); _mentionService.ProcessMention(new MentionModel { MentionedSourceId = comment.Id, CreatorId = _intranetUserService.GetCurrentUserId(), MentionedUserIds = mentionIds, Title = comment.Text.StripHtml().TrimByWordEnd(50), Url = content != null ? _commentLinkHelper.GetDetailsUrlWithComment(content, comment.Id) : _commentLinkHelper.GetDetailsUrlWithComment(comment.ActivityId, comment.Id), ActivityType = CommunicationTypeEnum.CommunicationSettings }); } }