diff --git a/AsbCloudApp/Requests/GetStatRequest.cs b/AsbCloudApp/Requests/GetStatRequest.cs index 5ebb9550..fbc53dd0 100644 --- a/AsbCloudApp/Requests/GetStatRequest.cs +++ b/AsbCloudApp/Requests/GetStatRequest.cs @@ -14,7 +14,7 @@ public class GetStatRequest: RequestBase public IEnumerable IdsWells { get; set; } = new List(); /// - /// id Ασπθλόωθκΰ + /// ροθρξκ κλώχει ασπθλόωθκξβ /// - public int? IdDriller { get; set; } + public IEnumerable IdsDrillers { get; set; } = new List(); } \ No newline at end of file diff --git a/AsbCloudInfrastructure/Repository/ScheduleRepository.cs b/AsbCloudInfrastructure/Repository/ScheduleRepository.cs index e7c2aa1f..29bf4f5b 100644 --- a/AsbCloudInfrastructure/Repository/ScheduleRepository.cs +++ b/AsbCloudInfrastructure/Repository/ScheduleRepository.cs @@ -57,11 +57,11 @@ namespace AsbCloudInfrastructure.Repository public async Task> GetPageAsync(GetStatRequest request, CancellationToken token) { var idWell = request.IdsWells; - var idDriller = request.IdDriller; + var idsDrillers = request.IdsDrillers; var query = GetQuery().Where(s => request.IdsWells.Contains(s.IdWell)); - if (idDriller is not null) + if (idsDrillers.Any()) { - query.Where(s => s.IdDriller == idDriller); + query = query.Where(s => idsDrillers.Contains(s.IdDriller)); } var result = await query.ToArrayAsync(token); diff --git a/AsbCloudWebApi/Controllers/DrillerController.cs b/AsbCloudWebApi/Controllers/DrillerController.cs index 0fa84e4a..48efca2c 100644 --- a/AsbCloudWebApi/Controllers/DrillerController.cs +++ b/AsbCloudWebApi/Controllers/DrillerController.cs @@ -1,7 +1,13 @@ ο»Ώusing AsbCloudApp.Data; +using AsbCloudApp.Requests; using AsbCloudApp.Services; using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; namespace AsbCloudWebApi.Controllers { @@ -13,8 +19,38 @@ namespace AsbCloudWebApi.Controllers [Authorize] public class DrillerController : CrudController> { - public DrillerController(ICrudRepository service) + private IScheduleRepository scheduleRepository; + + public DrillerController(ICrudRepository service, IScheduleRepository scheduleRepository) : base(service) - { } + { + this.scheduleRepository = scheduleRepository; + } + + /// + /// ΠŸΠΎΠ»ΡƒΡ‡ΠΈΡ‚ΡŒ список Π±ΡƒΡ€ΠΈΠ»ΡŒΡ‰ΠΈΠΊΠΎΠ² ΠΏΠΎ ΠΊΠ»ΡŽΡ‡Π°ΠΌ скваТин + /// + /// массив ΠΊΠ»ΡŽΡ‡Π΅ΠΉ скваТин + /// token + /// всС записи + [HttpGet("/api/drillers")] + [Permission] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + public async Task GetAsync([FromQuery] IEnumerable idsWells, CancellationToken token) + { + var request = new GetStatRequest() + { + IdsWells = idsWells, + }; + var schedulePage = await scheduleRepository.GetPageAsync(request, token); + var drillers = schedulePage + .Select(s => s.Driller) + .Where(d => d is not null) + .GroupBy(d => d.Id) + .Select(group => group.First()) + .OrderBy(d => d.Surname); + + return Ok(drillers); + } } }