2022-05-22 21:18:43 +05:00
|
|
|
|
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
|
|
|
|
|
{
|
2022-05-25 20:19:08 +05:00
|
|
|
|
[Route("api/schedule")]
|
2022-05-22 21:18:43 +05:00
|
|
|
|
[ApiController]
|
|
|
|
|
[Authorize]
|
2022-06-15 14:57:37 +05:00
|
|
|
|
public class ScheduleController : CrudWellRelatedController<ScheduleDto, IScheduleService>
|
2022-05-22 21:18:43 +05:00
|
|
|
|
{
|
|
|
|
|
private readonly IScheduleService scheduleService;
|
2022-05-26 15:32:23 +05:00
|
|
|
|
|
|
|
|
|
public ScheduleController(IScheduleService scheduleService, IWellService wellService)
|
2022-06-15 14:57:37 +05:00
|
|
|
|
: base(wellService, scheduleService)
|
2022-05-22 21:18:43 +05:00
|
|
|
|
{
|
|
|
|
|
this.scheduleService = service;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2022-05-26 13:34:40 +05:00
|
|
|
|
/// Получить бурильщика работавшего на скважине в определенное время.
|
2022-05-22 21:18:43 +05:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idWell">Идентификатор скважины</param>
|
2022-05-25 20:19:08 +05:00
|
|
|
|
/// <param name="workTime">Рабочее время</param>
|
2022-05-22 21:18:43 +05:00
|
|
|
|
/// <param name="token"></param>
|
2022-05-26 13:34:40 +05:00
|
|
|
|
/// <returns>бурильщик</returns>
|
|
|
|
|
[HttpGet("driller")]
|
2022-05-26 15:32:23 +05:00
|
|
|
|
public async Task<ActionResult<DrillerDto>> GetDrillerAsync(int idWell, DateTime workTime, CancellationToken token)
|
2022-05-22 21:18:43 +05:00
|
|
|
|
{
|
2022-06-15 14:57:37 +05:00
|
|
|
|
if (!await UserHasAccesToWellAsync(idWell, token))
|
2022-05-26 15:32:23 +05:00
|
|
|
|
return Forbid();
|
|
|
|
|
|
2022-06-15 14:57:37 +05:00
|
|
|
|
var result = await scheduleService.GetDrillerAsync(idWell, workTime, token);
|
2022-05-22 21:18:43 +05:00
|
|
|
|
return Ok(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|