public void Notify(NotifierData data)
        {
            var isCommunicationSettings = data.NotificationType.In(
                NotificationTypeEnum.CommentLikeAdded,
                NotificationTypeEnum.MonthlyMail); //TODO: temporary for communication settings

            var identity = new ActivityEventIdentity(isCommunicationSettings
                    ? CommunicationTypeEnum.CommunicationSettings
                    : data.ActivityType, data.NotificationType)
                           .AddNotifierIdentity(Type);

            var settings = _notificationSettingsService.Get <EmailNotifierTemplate>(identity);

            if (settings == null || !settings.IsEnabled)
            {
                return;
            }
            var receivers = _intranetUserService.GetMany(data.ReceiverIds).ToList();

            foreach (var receiverId in data.ReceiverIds)
            {
                var user = receivers.Find(receiver => receiver.Id == receiverId);

                var message = _notificationModelMapper.Map(data.Value, settings.Template, user);
                _mailService.Send(message);
            }
        }
        public void Notify(NotifierData data)
        {
            var identity = GetSettingsIdentity(data);

            var settings = _notificationSettingsService.Get <EmailNotifierTemplate>(identity);

            if (!settings.IsEnabled)
            {
                return;
            }
            var receivers = _intranetUserService.GetMany(data.ReceiverIds).ToList();

            foreach (var receiverId in data.ReceiverIds)
            {
                var user = receivers.Find(receiver => receiver.Id == receiverId);

                var message = _notificationModelMapper.Map(data.Value, settings.Template, user);
                _mailService.Send(message);

                _notificationRepository.Add(new global::Uintra.Notification.Notification()
                {
                    Id           = Guid.NewGuid(),
                    Date         = DateTime.UtcNow,
                    IsNotified   = true,
                    IsViewed     = false,
                    Type         = data.NotificationType.ToInt(),
                    NotifierType = NotifierTypeEnum.EmailNotifier.ToInt(),
                    Value        = new { message }.ToJson(),
                    ReceiverId   = receiverId
                });
            }
        }
Example #3
0
        public void Notify(NotifierData data)
        {
            var isCommunicationSettings = data.NotificationType.In(
                NotificationTypeEnum.CommentLikeAdded,
                NotificationTypeEnum.MonthlyMail) || //TODO: temporary for communication settings
                                          data.ActivityType.In(
                IntranetActivityTypeEnum.ContentPage,
                IntranetActivityTypeEnum.PagePromotion);

            var identity = new ActivityEventIdentity(isCommunicationSettings
                    ? CommunicationTypeEnum.CommunicationSettings
                    : data.ActivityType, data.NotificationType)
                           .AddNotifierIdentity(Type);

            var settings = _notificationSettingsService.Get <UiNotifierTemplate>(identity);

            if (settings == null || !settings.IsEnabled)
            {
                return;
            }
            var receivers = _intranetUserService.GetMany(data.ReceiverIds);

            var messages = receivers.Select(r => _notificationModelMapper.Map(data.Value, settings.Template, r));

            _notificationsService.Notify(messages);
        }
Example #4
0
        public virtual PartialViewResult List(Guid activityId)
        {
            var subscribs = _subscribeService.Get(activityId).ToList();

            var subscribersNames = subscribs.Count > 0
                ? _intranetUserService.GetMany(subscribs.Select(s => s.UserId)).Select(u => u.DisplayedName)
                : Enumerable.Empty <string>();

            return(PartialView(ListViewPath, subscribersNames));
        }
Example #5
0
        public void Notify(NotifierData data)
        {
            var identity = new ActivityEventIdentity(CommunicationTypeEnum.Member, data.NotificationType).AddNotifierIdentity(Type);
            var settings = _notificationSettingsService.Get <PopupNotifierTemplate>(identity);

            if (settings == null || !settings.IsEnabled)
            {
                return;
            }
            var receivers = _intranetUserService.GetMany(data.ReceiverIds);

            var messages = receivers.Select(r => _notificationModelMapper.Map(data.Value, settings.Template, r));

            _notificationsService.Notify(messages);
        }
        protected virtual (IList <ComingEventViewModel> events, int totalCount) GetComingEvents(int eventsAmount)
        {
            var events = GetComingEvents(DateTime.Now).AsList();

            var ownersDictionary = _intranetUserService.GetMany(events.Select(e => e.OwnerId)).ToDictionary(c => c.Id);

            var comingEvents = events
                               .Take(eventsAmount)
                               .Select(@event =>
            {
                var viewModel   = @event.Map <ComingEventViewModel>();
                viewModel.Owner = ownersDictionary[@event.OwnerId];
                viewModel.Links = _activityLinkService.GetLinks(@event.Id);
                return(viewModel);
            })
                               .ToList();

            return(comingEvents, events.Count);
        }
Example #7
0
        public void Notify(NotifierData data)
        {
            var isCommunicationSettings = data.NotificationType.In(
                NotificationTypeEnum.CommentLikeAdded,
                NotificationTypeEnum.MonthlyMail,
                IntranetActivityTypeEnum.ContentPage,
                IntranetActivityTypeEnum.PagePromotion);

            var identity = new ActivityEventIdentity(isCommunicationSettings
                    ? CommunicationTypeEnum.CommunicationSettings
                    : data.ActivityType, data.NotificationType)
                           .AddNotifierIdentity(Type);
            var settings = _notificationSettingsService.Get <UiNotifierTemplate>(identity);

            //if (settings == null) return;

            var desktopSettingsIdentity = new ActivityEventIdentity(settings.ActivityType, settings.NotificationType)
                                          .AddNotifierIdentity(NotifierTypeEnum.DesktopNotifier);
            var desktopSettings = _notificationSettingsService.Get <DesktopNotifierTemplate>(desktopSettingsIdentity);

            if (!settings.IsEnabled && !desktopSettings.IsEnabled)
            {
                return;
            }

            var receivers = _intranetUserService.GetMany(data.ReceiverIds);

            var messages = receivers.Select(receiver =>
            {
                var uiMsg = _notificationModelMapper.Map(data.Value, settings.Template, receiver);
                if (desktopSettings.IsEnabled)
                {
                    var desktopMsg       = _desktopNotificationModelMapper.Map(data.Value, desktopSettings.Template, receiver);
                    uiMsg.DesktopTitle   = desktopMsg.Title;
                    uiMsg.DesktopMessage = desktopMsg.Message;
                    uiMsg.IsDesktopNotificationEnabled = true;
                }
                return(uiMsg);
            });

            _notificationsService.Notify(messages);
        }
        private GroupMemberOverviewViewModel GetGroupMembersViewModel(Guid groupId)
        {
            var groupMembers   = _groupMemberService.GetGroupMemberByGroup(groupId);
            var membersIdsList = groupMembers.Select(s => s.MemberId).ToList();
            var groupUsers     = _userService.GetMany(membersIdsList);
            var group          = _groupService.Get(groupId);
            var currentUserId  = _userService.GetCurrentUserId();

            var groupMembersViewModel = groupUsers
                                        .Select(m => MapToMemberViewModel(m, group, currentUserId))
                                        .OrderByDescending(s => s.IsGroupAdmin)
                                        .ThenBy(s => s.GroupMember.DisplayedName)
                                        .ToList();

            var model = new GroupMemberOverviewViewModel
            {
                Members             = groupMembersViewModel,
                CanExcludeFromGroup = IsGroupCreator(currentUserId, group)
            };

            return(model);
        }
Example #9
0
        protected virtual IEnumerable <Tuple <Guid, string> > GetManyNames(IEnumerable <Guid> usersIds)
        {
            var users = _intranetUserService.GetMany(usersIds);

            return(users.Select(el => new Tuple <Guid, string>(el.Id, el.DisplayedName)));
        }