fix: fixes SonarQube issues
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
version: '3.9'
|
||||
|
||||
services:
|
||||
|
||||
shop-webapi:
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
version: '3.9'
|
||||
|
||||
networks:
|
||||
app-network:
|
||||
driver: bridge
|
||||
|
||||
@@ -25,6 +25,9 @@ internal abstract class BaseReadOnlyRepository<TQueryModel, Tkey>(IReadDbContext
|
||||
/// </summary>
|
||||
/// <param name="id">The id of the query model.</param>
|
||||
/// <returns>The query model.</returns>
|
||||
public async Task<TQueryModel> GetByIdAsync(Tkey id) =>
|
||||
await Collection.Find(queryModel => queryModel.Id.Equals(id)).FirstOrDefaultAsync();
|
||||
public async Task<TQueryModel> GetByIdAsync(Tkey id)
|
||||
{
|
||||
using var asyncCursor = await Collection.FindAsync(queryModel => queryModel.Id.Equals(id));
|
||||
return await asyncCursor.FirstOrDefaultAsync();
|
||||
}
|
||||
}
|
||||
@@ -11,10 +11,18 @@ namespace Shop.Query.Data.Repositories;
|
||||
internal class CustomerReadOnlyRepository(IReadDbContext readDbContext)
|
||||
: BaseReadOnlyRepository<CustomerQueryModel, Guid>(readDbContext), ICustomerReadOnlyRepository
|
||||
{
|
||||
public async Task<IEnumerable<CustomerQueryModel>> GetAllAsync() =>
|
||||
await Collection
|
||||
.Find(Builders<CustomerQueryModel>.Filter.Empty)
|
||||
.SortBy(customer => customer.FirstName)
|
||||
.ThenBy(customer => customer.DateOfBirth)
|
||||
.ToListAsync();
|
||||
public async Task<IEnumerable<CustomerQueryModel>> GetAllAsync()
|
||||
{
|
||||
var sort = Builders<CustomerQueryModel>.Sort
|
||||
.Ascending(customer => customer.FirstName)
|
||||
.Descending(customer => customer.DateOfBirth);
|
||||
|
||||
var findOptions = new FindOptions<CustomerQueryModel>
|
||||
{
|
||||
Sort = sort
|
||||
};
|
||||
|
||||
using var asyncCursor = await Collection.FindAsync(Builders<CustomerQueryModel>.Filter.Empty, findOptions);
|
||||
return await asyncCursor.ToListAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user