public PagedResult <AuditLog> GetPagedCurrentUserLog( int pageNumber = 1, int pageSize = 10, Direction orderDirection = Direction.Descending, DateTime?sinceDate = null) { if (pageSize <= 0 || pageNumber <= 0) { return(new PagedResult <AuditLog>(0, pageNumber, pageSize)); } IQuery <IAuditItem>?dateQuery = sinceDate.HasValue ? _sqlContext.Query <IAuditItem>().Where(x => x.CreateDate >= sinceDate) : null; var userId = _backofficeSecurityAccessor.BackOfficeSecurity?.GetUserId().Result ?? -1; IEnumerable <IAuditItem> result = _auditService.GetPagedItemsByUser( userId, pageNumber - 1, pageSize, out long totalRecords, orderDirection, customFilter: dateQuery); IEnumerable <AuditLog> mapped = _umbracoMapper.MapEnumerable <IAuditItem, AuditLog>(result).WhereNotNull(); return(new PagedResult <AuditLog>(totalRecords, pageNumber, pageSize) { Items = MapAvatarsAndNames(mapped) }); }
public RedirectUrlSearchResult SearchRedirectUrls(string searchTerm, int page = 0, int pageSize = 10) { var searchResult = new RedirectUrlSearchResult(); long resultCount; var redirects = string.IsNullOrWhiteSpace(searchTerm) ? _redirectUrlService.GetAllRedirectUrls(page, pageSize, out resultCount) : _redirectUrlService.SearchRedirectUrls(searchTerm, page, pageSize, out resultCount); searchResult.SearchResults = _umbracoMapper.MapEnumerable <IRedirectUrl, ContentRedirectUrl>(redirects).WhereNotNull(); searchResult.TotalCount = resultCount; searchResult.CurrentPage = page; searchResult.PageCount = ((int)resultCount + pageSize - 1) / pageSize; return(searchResult); }
/// <summary> /// Returns all user groups /// </summary> /// <returns></returns> public IEnumerable <UserGroupBasic> GetUserGroups(bool onlyCurrentUserGroups = true) { var allGroups = _umbracoMapper.MapEnumerable <IUserGroup, UserGroupBasic>(_userService.GetAllUserGroups()) .ToList(); var isAdmin = _backofficeSecurityAccessor.BackOfficeSecurity?.CurrentUser?.IsAdmin() ?? false; if (isAdmin) { return(allGroups); } if (onlyCurrentUserGroups == false) { //this user is not an admin so in that case we need to exclude all admin users allGroups.RemoveAt( allGroups.IndexOf(allGroups.Find(basic => basic.Alias == Constants.Security.AdminGroupAlias) !)); return(allGroups); } //we cannot return user groups that this user does not have access to var currentUserGroups = _backofficeSecurityAccessor.BackOfficeSecurity?.CurrentUser?.Groups.Select(x => x.Alias) .ToArray(); return(allGroups.WhereNotNull().Where(x => currentUserGroups?.Contains(x.Alias) ?? false).ToArray()); }
//[EnsureUserPermissionForContent("childId")] public IEnumerable <RelationDisplay> GetByChildId(int childId, string relationTypeAlias = "") { IRelation[] relations = _relationService.GetByChildId(childId).ToArray(); if (relations.Any() == false) { return(Enumerable.Empty <RelationDisplay>()); } if (string.IsNullOrWhiteSpace(relationTypeAlias) == false) { return (_umbracoMapper.MapEnumerable <IRelation, RelationDisplay>( relations.Where(x => x.RelationType.Alias.InvariantEquals(relationTypeAlias))).WhereNotNull()); } return(_umbracoMapper.MapEnumerable <IRelation, RelationDisplay>(relations).WhereNotNull()); }
/// <summary> /// Searches with the <see cref="IEntityService"/> for results based on the entity type /// </summary> /// <param name="objectType"></param> /// <param name="query"></param> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <param name="totalFound"></param> /// <param name="searchFrom"></param> /// <returns></returns> public IEnumerable <SearchResultEntity?> EntitySearch(UmbracoObjectTypes objectType, string query, int pageSize, long pageIndex, out long totalFound, string?searchFrom = null) { //if it's a GUID, match it Guid.TryParse(query, out var g); var results = _entityService.GetPagedDescendants(objectType, pageIndex, pageSize, out totalFound, filter: _sqlContext.Query <IUmbracoEntity>().Where(x => x.Name !.Contains(query) || x.Key == g)); return(_mapper.MapEnumerable <IEntitySlim, SearchResultEntity>(results)); }
public ActionResult<IEnumerable<UserDisplay?>> GetByIds([FromJsonPath] int[] ids) { if (ids == null) { return NotFound(); } if (ids.Length == 0) { return Enumerable.Empty<UserDisplay>().ToList(); } IEnumerable<IUser>? users = _userService.GetUsersById(ids); if (users == null) { return NotFound(); } List<UserDisplay> result = _umbracoMapper.MapEnumerable<IUser, UserDisplay>(users); return result; }
/// <inheritdoc /> public IEnumerable <TagModel> GetAllTags(string group = null, string culture = null) { return(_mapper.MapEnumerable <ITag, TagModel>(_tagService.GetAllTags(group, culture))); }
/// <inheritdoc /> public IEnumerable <TagModel?> GetAllTags(string?group = null, string?culture = null) => _mapper.MapEnumerable <ITag, TagModel>(_tagService.GetAllTags(group, culture));