forked from ddrilling/AsbCloudServer
WellOperationRepository.GetCategories(..) add arg, to filter categories/
This commit is contained in:
parent
eb18d73dd0
commit
7779116c8a
@ -17,7 +17,7 @@ namespace AsbCloudApp.Repositories
|
||||
/// список названий операций
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
IEnumerable<WellOperationCategoryDto> GetCategories();
|
||||
IEnumerable<WellOperationCategoryDto> GetCategories(bool includeParents);
|
||||
|
||||
/// <summary>
|
||||
/// Список секций
|
||||
|
@ -34,21 +34,26 @@ namespace AsbCloudInfrastructure.Repository
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<WellOperationCategoryDto> GetCategories()
|
||||
public IEnumerable<WellOperationCategoryDto> GetCategories(bool includeParents)
|
||||
{
|
||||
var allCategories = memoryCache
|
||||
var categories = memoryCache
|
||||
.GetOrCreateBasic<WellOperationCategory>(db);
|
||||
|
||||
var parentIds = allCategories
|
||||
.Select(o => o.IdParent)
|
||||
.Distinct();
|
||||
if (!includeParents)
|
||||
{
|
||||
var parentIds = categories
|
||||
.Select(o => o.IdParent)
|
||||
.Distinct();
|
||||
|
||||
var operationCategories = allCategories
|
||||
.Where(o => !parentIds.Contains(o.Id))
|
||||
categories = categories
|
||||
.Where(o => !parentIds.Contains(o.Id));
|
||||
}
|
||||
|
||||
var result = categories
|
||||
.OrderBy(o => o.IdParent)
|
||||
.ThenBy(o => o.Name);
|
||||
.ThenBy(o => o.Name)
|
||||
.Adapt<IEnumerable<WellOperationCategoryDto>>();
|
||||
|
||||
var result = operationCategories.Adapt<IEnumerable<WellOperationCategoryDto>>();
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -149,7 +154,7 @@ namespace AsbCloudInfrastructure.Repository
|
||||
DurationDepth = o.DepthEnd - o.DepthStart
|
||||
})
|
||||
.ToListAsync(token);
|
||||
var parentRelationDictionary = GetCategories()
|
||||
var parentRelationDictionary = GetCategories(true)
|
||||
.ToDictionary(c => c.Id, c => new
|
||||
{
|
||||
c.Name,
|
||||
|
@ -138,7 +138,7 @@ namespace AsbCloudWebApi.Controllers.SAUB
|
||||
IEnumerable<int> idsWells;
|
||||
if (idCluster is not null)
|
||||
{
|
||||
var companyWells = await wellService.GetWellsByCompanyAsync((int)idCompany, token);
|
||||
var companyWells = await wellService.GetAsync(new() { IdCompany = idCompany }, token);
|
||||
idsWells = companyWells.Where(w => w.IdCluster == idCluster)
|
||||
.Select(w=>w.Id);
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
[ProducesResponseType(typeof(IEnumerable<WellOperationCategoryDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||
public IActionResult GetCategories()
|
||||
{
|
||||
var result = operationRepository.GetCategories();
|
||||
var result = operationRepository.GetCategories(false);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user