Exemplo n.º 1
0
        public override bool IsActual(IIntranetActivity activity)
        {
            var news = (NewsBase)activity;

            var isActual = base.IsActual(news) && news.PublishDate <= DateTime.UtcNow && !IsShowIfUnpublish(news);

            return(isActual);
        }
Exemplo n.º 2
0
 public override Guid Create(IIntranetActivity activity)
 {
     return(base.Create(activity, activityId =>
     {
         var subscribeSettings = Map(activity);
         subscribeSettings.ActivityId = activityId;
         _activitySubscribeSettingService.Create(subscribeSettings);
     }));
 }
Exemplo n.º 3
0
 protected virtual void AssignLinkPreview(Guid newActivityId, IIntranetActivity activity)
 {
     if (activity is IHasLinkPreview linkPreview)
     {
         if (linkPreview.LinkPreviewId.HasValue)
         {
             _activityLinkPreviewService.AddLinkPreview(newActivityId, linkPreview.LinkPreviewId.Value);
         }
     }
 }
Exemplo n.º 4
0
 protected virtual async Task AssignLinkPreviewAsync(Guid newActivityId, IIntranetActivity activity)
 {
     if (activity is IHasLinkPreview linkPreview)
     {
         if (linkPreview.LinkPreviewId.HasValue)
         {
             await _activityLinkPreviewService.AddLinkPreviewAsync(newActivityId, linkPreview.LinkPreviewId.Value);
         }
     }
 }
Exemplo n.º 5
0
        protected virtual bool CanPerform(IIntranetActivity activity, PermissionActionEnum action, PermissionActionEnum administrationAction)
        {
            var currentMember = _intranetMemberService.GetCurrentMember();
            var ownerId       = ((IHaveOwner)activity).OwnerId;
            var isOwner       = ownerId == currentMember.Id;

            var act    = isOwner ? action : administrationAction;
            var result = _permissionsService.Check(currentMember, new PermissionSettingIdentity(act, PermissionActivityType));

            return(result);
        }
 public ActivityReminderDataModel GetActivityReminderDataModel(IIntranetActivity activity, Enum activityType)
 {
     return(new ActivityReminderDataModel
     {
         Url = _linkService.GetLinks(activity.Id).Details,
         Title = activity.Title,
         NotificationType = activityType,
         ActivityType = activity.Type,
         IsPinned = activity.IsPinned,
         IsPinActual = activity.IsPinActual
     });
 }
Exemplo n.º 7
0
 public ActivityNotifierDataModel GetActivityNotifierDataModel(IIntranetActivity activity, Enum notificationType, Guid notifierId)
 {
     return(new ActivityNotifierDataModel
     {
         NotificationType = notificationType,
         ActivityType = activity.Type,
         Title = GetNotifierDataTitle(activity).TrimByWordEnd(MaxTitleLength),
         Url = _linkService.GetLinks(activity.Id).Details,
         NotifierId = notifierId,
         IsPinned = activity.IsPinned,
         IsPinActual = activity.IsPinActual
     });
 }
Exemplo n.º 8
0
 public CommentNotifierDataModel GetCommentNotifierDataModel(IIntranetActivity activity, CommentModel comment, Enum notificationType, Guid notifierId)
 {
     return(new CommentNotifierDataModel
     {
         CommentId = comment.Id,
         NotificationType = notificationType,
         NotifierId = notifierId,
         Title = GetNotifierDataTitle(activity).TrimByWordEnd(MaxTitleLength),
         Url = _commentLinkHelper.GetDetailsUrlWithComment(activity.Id, comment.Id),
         IsPinned = activity.IsPinned,
         IsPinActual = activity.IsPinActual
     });
 }
Exemplo n.º 9
0
        public virtual bool IsPinActual(IIntranetActivity activity)
        {
            if (!activity.IsPinned)
            {
                return(false);
            }

            if (activity.EndPinDate.HasValue)
            {
                return(activity.EndPinDate.Value.ToUniversalTime() > DateTime.UtcNow);
            }

            return(true);
        }
Exemplo n.º 10
0
 public LikesNotifierDataModel GetLikesNotifierDataModel(IIntranetActivity activity, Enum notificationType, Guid notifierId)
 {
     return(new LikesNotifierDataModel
     {
         Title = GetNotifierDataTitle(activity).TrimByWordEnd(MaxTitleLength),
         NotificationType = notificationType,
         ActivityType = activity.Type,
         NotifierId = notifierId,
         CreatedDate = DateTime.UtcNow,
         Url = _linkService.GetLinks(activity.Id).Details,
         IsPinned = activity.IsPinned,
         IsPinActual = activity.IsPinActual
     });
 }
Exemplo n.º 11
0
        protected virtual void Save(IIntranetActivity activity, Action <IIntranetActivity> afterSaveAction)
        {
            var entity = _activityRepository.Get(activity.Id);

            entity.JsonData = activity.ToJson();

            _activityLocationService.Set(activity.Id, activity.Location);
            _activityRepository.Update(entity);
            _intranetMediaService.Update(activity.Id, activity.MediaIds.JoinToString());
            AssignLinkPreview(activity);

            afterSaveAction?.Invoke(activity);
            UpdateActivityCache(activity.Id);
        }
Exemplo n.º 12
0
        protected virtual async Task AssignLinkPreviewAsync(IIntranetActivity activity)
        {
            if (activity is IHasLinkPreview linkPreview)
            {
                if (!linkPreview.LinkPreviewId.HasValue)
                {
                    await _activityLinkPreviewService.RemovePreviewRelationsAsync(activity.Id);
                }

                if (linkPreview.LinkPreviewId.HasValue)
                {
                    await _activityLinkPreviewService.UpdateLinkPreviewAsync(activity.Id, linkPreview.LinkPreviewId.Value);
                }
            }
        }
Exemplo n.º 13
0
        protected virtual void AssignLinkPreview(IIntranetActivity activity)
        {
            if (activity is IHasLinkPreview linkPreview)
            {
                if (!linkPreview.LinkPreviewId.HasValue)
                {
                    _activityLinkPreviewService.RemovePreviewRelations(activity.Id);
                }

                if (linkPreview.LinkPreviewId.HasValue)
                {
                    _activityLinkPreviewService.UpdateLinkPreview(activity.Id, linkPreview.LinkPreviewId.Value);
                }
            }
        }
Exemplo n.º 14
0
        protected virtual async Task SaveAsync(IIntranetActivity activity, Action <IIntranetActivity> afterSaveAction)
        {
            var entity = await _activityRepository.GetAsync(activity.Id);

            entity.JsonData = activity.ToJson();

            await _activityLocationService.SetAsync(activity.Id, activity.Location);

            await _activityRepository.UpdateAsync(entity);

            await _intranetMediaService.UpdateAsync(activity.Id, activity.MediaIds.JoinToString());

            await AssignLinkPreviewAsync(activity);

            afterSaveAction?.Invoke(activity);
            await UpdateActivityCacheAsync(activity.Id);
        }
Exemplo n.º 15
0
        private bool CanPerform(IIntranetActivity cached, IntranetActivityActionEnum action)
        {
            var currentUser = _intranetUserService.GetCurrentUser();

            var isWebmaster = _permissionsService.IsUserWebmaster(currentUser);

            if (isWebmaster)
            {
                return(true);
            }

            var ownerId = Get(cached.Id).OwnerId;
            var isOwner = ownerId == currentUser.Id;

            var isUserHasPermissions = _permissionsService.IsRoleHasPermissions(currentUser.Role, Type, action);

            return(isOwner && isUserHasPermissions);
        }
Exemplo n.º 16
0
        protected virtual Guid Create(IIntranetActivity activity, Action <Guid> afterCreateAction)
        {
            var newActivity = new IntranetActivityEntity {
                Type = Type.ToInt(), JsonData = activity.ToJson()
            };

            _activityRepository.Create(newActivity);
            var newActivityId = newActivity.Id;

            _activityLocationService.Set(newActivityId, activity.Location);
            _intranetMediaService.Create(newActivityId, activity.MediaIds.JoinToString());
            AssignLinkPreview(newActivityId, activity);

            afterCreateAction?.Invoke(newActivityId);

            UpdateActivityCache(newActivityId);
            return(newActivityId);
        }
Exemplo n.º 17
0
        public override bool CanEdit(IIntranetActivity activity)
        {
            var currentUser = _intranetUserService.GetCurrentUser();

            var isWebmaster = _permissionsService.IsUserWebmaster(currentUser);

            if (isWebmaster)
            {
                return(true);
            }

            var ownerId = Get(activity.Id).OwnerId;
            var isOwner = ownerId == currentUser.Id;

            var isUserHasPermissions = _permissionsService.IsRoleHasPermissions(currentUser.Role, Type, IntranetActivityActionEnum.Edit);

            return(isOwner && isUserHasPermissions);
        }
        internal INotifierDataValue GetNotifierDataValue(OldNotifierData oldData, IIntranetActivity activity, Enum notificationType)
        {
            INotifierDataValue result;

            switch (notificationType)
            {
            case NotificationTypeEnum.ActivityLikeAdded:
            {
                result = _notifierDataHelper.GetLikesNotifierDataModel(activity, notificationType, oldData.NotifierId);
                break;
            }

            case NotificationTypeEnum.CommentAdded:
            case NotificationTypeEnum.CommentReplied:
            case NotificationTypeEnum.CommentEdited:
            case NotificationTypeEnum.CommentLikeAdded:
            {
                var commentId = ParseCommentId(oldData.Url);
                var comment   = _commentsService.Get(commentId);
                result = _notifierDataHelper.GetCommentNotifierDataModel(activity, comment, notificationType, oldData.NotifierId);
                break;
            }

            case NotificationTypeEnum.BeforeStart:
            {
                result = _notifierDataHelper.GetActivityReminderDataModel(activity, notificationType);
                break;
            }

            case NotificationTypeEnum.EventHided:
            case NotificationTypeEnum.EventUpdated:
            {
                result = _notifierDataHelper.GetActivityNotifierDataModel(activity, notificationType, oldData.NotifierId);
                break;
            }

            default:
                result = null;
                break;
            }

            return(result);
        }
Exemplo n.º 19
0
        public ActivityReminderDataModel GetActivityReminderDataModel(IIntranetActivity activity, Enum activityType)
        {
            var model = new ActivityReminderDataModel
            {
                Url              = _linkService.GetLinks(activity.Id).Details,
                Title            = activity.Title,
                NotificationType = activityType,
                ActivityType     = activity.Type,
                IsPinned         = activity.IsPinned,
                IsPinActual      = activity.IsPinActual
            };

            if (activity.Type is IntranetActivityTypeEnum.Events)
            {
                var @event = (Event)activity;
                model.StartDate = @event.StartDate;
            }

            return(model);
        }
Exemplo n.º 20
0
        public override bool IsActual(IIntranetActivity activity)
        {
            var news     = (NewsBase)activity;
            var isActual = base.IsActual(news);

            if (!isActual)
            {
                return(false);
            }

            if (IsExpired(news))
            {
                news.IsHidden      = true;
                news.UnpublishDate = null;
                Save(news);
                return(false);
            }

            return(news.PublishDate <= DateTime.UtcNow || IsOwner(news));
        }
 public virtual bool CanDelete(IIntranetActivity activity) => false;
Exemplo n.º 22
0
 public virtual bool CanEdit(IIntranetActivity activity) =>
 CanPerform(activity, PermissionActionEnum.Edit, PermissionActionEnum.EditOther);
Exemplo n.º 23
0
 public virtual bool CanDelete(IIntranetActivity activity) =>
 CanPerform(activity, PermissionActionEnum.Delete, PermissionActionEnum.DeleteOther);
        public virtual bool IsActual(IIntranetActivity activity)
        {
            var pagePromotion = activity as T;

            return(pagePromotion != null && !pagePromotion.IsHidden && pagePromotion.PublishDate <= DateTime.UtcNow);
        }
 public virtual bool CanEdit(IIntranetActivity activity) => false;
Exemplo n.º 26
0
 private static string GetNotifierDataTitle(IIntranetActivity activity)
 => activity.Type is IntranetActivityTypeEnum.Bulletins ? activity.Description.StripHtml() : activity.Title;
 public bool IsPinActual(IIntranetActivity activity) => false;
Exemplo n.º 28
0
        public async Task <ActivityReminderDataModel> GetActivityReminderDataModelAsync(IIntranetActivity activity, Enum notificationType)
        {
            var model = new ActivityReminderDataModel
            {
                Url              = (await _linkService.GetLinksAsync(activity.Id))?.Details,
                Title            = activity.Title,
                NotificationType = notificationType,
                ActivityType     = activity.Type,
                IsPinned         = activity.IsPinned,
                IsPinActual      = activity.IsPinActual
            };

            if (activity.Type is IntranetActivityTypeEnum.Events)
            {
                var @event = (Event)activity;
                model.StartDate = @event.StartDate;
            }

            return(model);
        }
 public virtual void Save(IIntranetActivity activity)
 {
     UpdateActivityCache(activity.Id);
 }
 public virtual Guid Create(IIntranetActivity activity) => activity.Id;