Merge branch 'fix/pagination-container-items' into dev

This commit is contained in:
ngfrolov 2023-07-18 16:47:30 +05:00
commit 1d94a64e49
Signed by untrusted user who does not match committer: ng.frolov
GPG Key ID: E99907A0357B29A7
5 changed files with 12 additions and 17 deletions

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
namespace AsbCloudApp.Data
{
@ -13,16 +14,7 @@ namespace AsbCloudApp.Data
/// </summary>
public PaginationContainer()
{
Items = new List<T>(4);
}
/// <summary>
/// конструктор
/// </summary>
/// <param name="capacity"></param>
public PaginationContainer(int capacity)
{
Items = new List<T>(capacity);
Items = Enumerable.Empty<T>();
}
/// <summary>
@ -43,6 +35,6 @@ namespace AsbCloudApp.Data
/// <summary>
/// Данные
/// </summary>
public List<T> Items { get; set; }
public IEnumerable<T> Items { get; set; }
}
}

View File

@ -111,7 +111,7 @@ namespace AsbCloudInfrastructure.Repository
.ToListAsync(token)
.ConfigureAwait(false);
result.Items = entities.Select(e => Convert(e)).ToList();
result.Items = entities.Select(e => Convert(e));
return result;
}

View File

@ -70,14 +70,14 @@ public class NotificationRepository : CrudCacheRepositoryBase<NotificationDto, N
if (result.Count < skip)
return result;
result.Items = await query
.SortBy(request.SortFields)
.Skip(skip)
.Take(take)
.AsNoTracking()
.Select(x => x.Adapt<NotificationDto>())
.ToListAsync(cancellationToken);
.ToArrayAsync(cancellationToken);
return result;
}

View File

@ -165,7 +165,7 @@ namespace AsbCloudInfrastructure.Repository
.Skip(result.Skip)
.Take(result.Take);
result.Items = await query.ToListAsync(token);
result.Items = await query.ToArrayAsync(token);
return result;
}

View File

@ -101,6 +101,8 @@ namespace AsbCloudInfrastructure.Services.SAUB
var eventsDict = events.ToDictionary(x=>x.IdEvent, x => x);
var usersDict = users.ToDictionary(x => x.IdUser, x => x);
var messagesDtoList = new List<MessageDto>();
foreach (var message in messagesList)
{
var messageDto = new MessageDto
@ -126,10 +128,11 @@ namespace AsbCloudInfrastructure.Services.SAUB
messageDto.CategoryId = e.IdCategory;
messageDto.Message = e.MakeMessageText(message);
}
result.Items.Add(messageDto);
messagesDtoList.Add(messageDto);
}
result.Items = result.Items.Concat(messagesDtoList);
return result;
}