public void AssignMembersToGroup() { var members = _intranetMemberService.GetAll().Where(s => !s.Inactive).Take(50); var creator = _intranetMemberService.GetByEmail("*****@*****.**"); _groupMemberService.Create(new GroupCreateModel() { Description = "Automation created", Title = $"{DateTime.Now.Ticks}", }, new GroupMemberSubscriptionModel() { IsAdmin = true, MemberId = creator.Id }); var groupId = _groupService.GetAll().OrderByDescending(g => g.CreatedDate).First().Id; var subscriptions = members.Except(creator.ToEnumerableOfOne()).Select(m => new GroupMemberSubscriptionModel() { MemberId = m.Id, IsAdmin = false, }); _groupMemberService.AddMany(groupId, subscriptions); }
public virtual void FillIndex() { var actualUsers = _intranetMemberService.GetAll().Where(u => !u.Inactive).ToList(); var searchableUsers = actualUsers.Select(_searchableMemberMapper.Map); _elasticMemberIndex.Index(searchableUsers); }
protected virtual IEnumerable <IIntranetMember> GetUsersWithAccess(PermissionSettingIdentity permissionSettingIdentity) { var result = _intranetMemberService .GetAll() .Where(member => _permissionsService.Check(member, permissionSettingIdentity)) .OrderBy(user => user.DisplayedName); return(result); }
public virtual IndexedModelResult FillIndex() { try { var actualUsers = _intranetMemberService.GetAll().Where(u => !u.Inactive); var searchableUsers = actualUsers.Select(_searchableMemberMapper.Map).ToList(); _elasticMemberIndex.Index(searchableUsers); return(_indexerDiagnosticService.GetSuccessResult(typeof(MembersIndexer <T>).Name, searchableUsers)); } catch (Exception e) { return(_indexerDiagnosticService.GetFailedResult(e.Message + e.StackTrace, typeof(MembersIndexer <T>).Name)); } }
protected virtual IEnumerable <CommentViewModel> GetCommentViews(IEnumerable <CommentModel> comments) { comments = comments.OrderBy(c => c.CreatedDate); var commentsList = comments as List <CommentModel> ?? comments.ToList(); var currentMemberId = _intranetMemberService.GetCurrentMember().Id; var creators = _intranetMemberService.GetAll().ToList(); var replies = commentsList.FindAll(_commentsService.IsReply); foreach (var comment in commentsList.FindAll(c => !_commentsService.IsReply(c))) { var model = GetCommentView(comment, currentMemberId, creators.SingleOrDefault(c => c.Id == comment.UserId)); var commentReplies = replies.FindAll(reply => reply.ParentId == model.Id); model.Replies = commentReplies.Select(reply => GetCommentView(reply, currentMemberId, creators.SingleOrDefault(c => c.Id == reply.UserId))); yield return(model); } }
public void CreateAndSendMail() { var currentDate = DateTime.UtcNow; var allUsers = _intranetMemberService.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.Error <MonthlyEmailServiceBase>(ex); } }); } }
public virtual IEnumerable <CommentViewModel> GetCommentViews(IEnumerable <CommentModel> comments) { var commentsList = comments.OrderBy(c => c.CreatedDate).ToArray(); var currentMemberId = _intranetMemberService.GetCurrentMemberId(); var creators = _intranetMemberService.GetAll().ToArray(); var replies = commentsList.Where(_commentsService.IsReply); return(commentsList .Where(c => !_commentsService.IsReply(c)) .Select(comment => { var model = GetCommentView(comment, currentMemberId, creators.SingleOrDefault(c => c.Id == comment.UserId)); var commentReplies = replies.Where(reply => reply.ParentId == model.Id); model.Replies = commentReplies .Select(reply => GetCommentView(reply, currentMemberId, creators.SingleOrDefault(c => c.Id == reply.UserId))); return model; })); }
public IEnumerable <IIntranetMember> GetAll() { return(_intranetMemberService.GetAll().OrderBy(user => user.DisplayedName)); }
private IEnumerable <IntranetMember> GetUsersWithAccess(PermissionSettingIdentity permissionSettingIdentity) => _memberService .GetAll() .Where(member => _permissionsService.Check(member, permissionSettingIdentity)) .OrderBy(user => user.DisplayedName) .ToArray();