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 { /// <summary> /// Расписание бурильщиков /// </summary> [Route("api/schedule")] [ApiController] [Authorize] public class ScheduleController : CrudWellRelatedController<ScheduleDto, IScheduleRepository> { private readonly IScheduleRepository scheduleService; public ScheduleController(IScheduleRepository scheduleService, IWellService wellService) : base(wellService, scheduleService) { this.scheduleService = service; } /// <summary> /// Получить бурильщика работавшего на скважине в определенное время. /// </summary> /// <param name="idWell">Идентификатор скважины</param> /// <param name="workTime">Рабочее время</param> /// <param name="token"></param> /// <returns>бурильщик</returns> [HttpGet("driller")] public async Task<ActionResult<DrillerDto?>> GetDrillerAsync(int idWell, DateTime workTime, CancellationToken token) { if (!await UserHasAccesToWellAsync(idWell, token)) return Forbid(); var result = await scheduleService.GetOrDefaultDrillerAsync(idWell, workTime, token); return Ok(result); } } }