forked from ddrilling/AsbCloudServer
Add WellSectionTypes dbSet
This commit is contained in:
parent
b218187117
commit
9497aaf7e3
@ -13,5 +13,6 @@ namespace AsbCloudApp.Services
|
||||
Task<IEnumerable<WellSectionDto>> InsertRangeAsync(int idWell, IEnumerable<WellSectionDto> newItems, CancellationToken token = default);
|
||||
Task<WellSectionDto> UpdateAsync(int idWell, int idSection, WellSectionDto item, CancellationToken token = default);
|
||||
Task<int> DeleteAsync(IEnumerable<int> ids, CancellationToken token = default);
|
||||
Task<string[]> GetTypesAsync(CancellationToken token);
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ namespace AsbCloudDb.Model
|
||||
public virtual DbSet<TelemetryOperation> TelemetryOperations { get; set; }
|
||||
public virtual DbSet<TelemetryAnalysis> TelemetryAnalysis { get; set; }
|
||||
public virtual DbSet<WellSection> WellSections { get; set; }
|
||||
public virtual DbSet<WellSectionType> WellSectionTypes { get; set; }
|
||||
public virtual DbSet<WellOperation> WellOperations { get; set; }
|
||||
public virtual DbSet<WellType> WellTypes { get; set; }
|
||||
public virtual DbSet<LastData> LastData { get; set; }
|
||||
|
@ -26,6 +26,7 @@ namespace AsbCloudDb.Model
|
||||
DbSet<TelemetryAnalysis> TelemetryAnalysis { get; set; }
|
||||
DbSet<Well> Wells { get; set; }
|
||||
DbSet<WellSection> WellSections { get; set; }
|
||||
DbSet<WellSectionType> WellSectionTypes { get; set; }
|
||||
DbSet<WellOperation> WellOperations { get; set; }
|
||||
DbSet<WellType> WellTypes { get; set; }
|
||||
DbSet<LastData> LastData { get; set; }
|
||||
|
@ -25,6 +25,9 @@ namespace AsbCloudInfrastructure.Services
|
||||
cachedSectionsTypes = cache.GetCachedTable<WellSectionType>((DbContext)context);
|
||||
}
|
||||
|
||||
public Task<string[]> GetTypesAsync(CancellationToken token) =>
|
||||
context.WellSectionTypes.Select(e => e.Caption).Distinct().AsNoTracking().ToArrayAsync(token);
|
||||
|
||||
public async Task<PaginationContainer<WellSectionDto>> GetAllByWellIdAsync(int idWell, int skip, int take, CancellationToken token = default)
|
||||
{
|
||||
var query = dbSet
|
||||
|
@ -26,7 +26,16 @@ namespace AsbCloudWebApi.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(IEnumerable<WellSectionDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||
[Route("types")]
|
||||
[ProducesResponseType(typeof(string[]), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetTypesAsync(CancellationToken token = default)
|
||||
{
|
||||
var result = await sectionsService.GetTypesAsync(token).ConfigureAwait(false);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(PaginationContainer<WellSectionDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetAllAsync(int idWell, int skip = 0, int take = 32,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
@ -75,13 +84,13 @@ namespace AsbCloudWebApi.Controllers
|
||||
|
||||
[HttpDelete("{idSection}")]
|
||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> DeleteAsync(int idWell, int idSection, CancellationToken token = default)
|
||||
public async Task<IActionResult> DeleteAsync(int idWell, int idItem, CancellationToken token = default)
|
||||
{
|
||||
if (!await CanUserAccessToWellAsync(idWell,
|
||||
token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var result = await sectionsService.DeleteAsync(new int[] { idSection }, token).ConfigureAwait(false);
|
||||
var result = await sectionsService.DeleteAsync(new int[] { idItem }, token).ConfigureAwait(false);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user