using AsbCloudApp.Data; using AsbCloudApp.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System; using System.Threading; using System.Threading.Tasks; namespace AsbCloudWebApi.Controllers; /// /// Расписание бурильщиков /// [Route("api/schedule")] [ApiController] [Authorize] public class ScheduleController : CrudWellRelatedController { private readonly IScheduleRepository scheduleService; public ScheduleController(IScheduleRepository scheduleService, IWellService wellService) : base(wellService, scheduleService) { this.scheduleService = service; } /// /// Получить бурильщика работавшего на скважине в определенное время. /// /// Идентификатор скважины /// Рабочее время /// /// бурильщик [HttpGet("driller")] public async Task> GetDrillerAsync(int idWell, DateTimeOffset workTime, CancellationToken token) { if (!await UserHasAccesToWellAsync(idWell, token)) return Forbid(); var result = await scheduleService.GetOrDefaultDrillerAsync(idWell, workTime, token); return Ok(result); } }