Beispiel #1
0
        protected virtual IEnumerable <IIntranetUser> GetUsersWithAccess(Enum activityType, IntranetActivityActionEnum action)
        {
            var result = _intranetUserService
                         .GetAll()
                         .Where(user => _permissionsService.IsUserHasAccess(user, activityType, action))
                         .OrderBy(user => user.DisplayedName);

            return(result);
        }
        protected virtual IEnumerable <CommentViewModel> GetCommentViews(IEnumerable <CommentModel> comments)
        {
            comments = comments.OrderBy(c => c.CreatedDate);
            var commentsList  = comments as List <CommentModel> ?? comments.ToList();
            var currentUserId = _intranetUserService.GetCurrentUser().Id;
            var creators      = _intranetUserService.GetAll().ToList();
            var replies       = commentsList.FindAll(_commentsService.IsReply);

            foreach (var comment in commentsList.FindAll(c => !_commentsService.IsReply(c)))
            {
                var model          = GetCommentView(comment, currentUserId, creators.SingleOrDefault(c => c.Id == comment.UserId));
                var commentReplies = replies.FindAll(reply => reply.ParentId == model.Id);
                model.Replies = commentReplies.Select(reply => GetCommentView(reply, currentUserId, creators.SingleOrDefault(c => c.Id == reply.UserId)));
                yield return(model);
            }
        }
Beispiel #3
0
        public void CreateAndSendMail()
        {
            var currentDate = DateTime.Now;

            var allUsers     = _intranetUserService.GetAll();
            var monthlyMails = allUsers
                               .Select(user => user.Id.Pipe(GetUserActivitiesFilteredByUserTags).Pipe(userActivities => TryGetMonthlyMail(userActivities, user)))
                               .ToList();

            var identity = new ActivityEventIdentity(
                CommunicationTypeEnum.CommunicationSettings,
                NotificationTypeEnum.MonthlyMail)
                           .AddNotifierIdentity(NotifierTypeEnum.EmailNotifier);

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

            if (!settings.IsEnabled)
            {
                return;
            }

            foreach (var monthlyMail in monthlyMails)
            {
                monthlyMail.Do(some: mail =>
                {
                    var mailModel = GetMonthlyMailModel(mail.user, mail.monthlyMail, settings.Template);
                    try
                    {
                        _mailService.SendMailByTypeAndDay(
                            mailModel,
                            mail.user.Email,
                            currentDate,
                            NotificationTypeEnum.MonthlyMail);
                    }
                    catch (Exception ex)
                    {
                        _logger.Log(ex);
                    }
                });
            }
        }
Beispiel #4
0
 public IEnumerable <IIntranetUser> GetAll()
 {
     return(_intranetUserService.GetAll().OrderBy(user => user.DisplayedName));
 }