feat(api): appInWorkContoller добавлены методы Get
This commit is contained in:
@@ -59,7 +59,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
if (!resultValidate.IsValid)
|
if (!resultValidate.IsValid)
|
||||||
return BadRequest(new Response(resultValidate.Errors));
|
return BadRequest(new Response(resultValidate.Errors));
|
||||||
|
|
||||||
var existSameAiW = await applicationsInWorkService.Get(request.ApplicationId, request.WorkId);
|
var existSameAiW = await applicationsInWorkService.GetAsync(request.ApplicationId, request.WorkId);
|
||||||
|
|
||||||
if (existSameAiW != null)
|
if (existSameAiW != null)
|
||||||
return BadRequest(new Response(false, new List<ErrorModel> {
|
return BadRequest(new Response(false, new List<ErrorModel> {
|
||||||
@@ -94,7 +94,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получить список регламентных работ(ApplicationInWork)
|
/// Получить список заданий на выполнение работ(ApplicationInWork) постранично
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet(ApiRoutes.Job.GetAll)]
|
[HttpGet(ApiRoutes.Job.GetAll)]
|
||||||
@@ -120,5 +120,25 @@ namespace PARR.API.Controllers.V1
|
|||||||
|
|
||||||
return Ok(paginationResponse);
|
return Ok(paginationResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить задание на выполнение работ по id
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet(ApiRoutes.Job.Get)]
|
||||||
|
public async Task<IActionResult> GetById([FromRoute] Guid id)
|
||||||
|
{
|
||||||
|
var applicationInWork = await applicationsInWorkService.Get()
|
||||||
|
.FirstOrDefaultAsync(t => t.Id == id);
|
||||||
|
|
||||||
|
if (applicationInWork == null)
|
||||||
|
return NotFound();
|
||||||
|
|
||||||
|
var response = mapper.Map<ApplicationInWorkResponse>(applicationInWork);
|
||||||
|
|
||||||
|
return Ok(new Response<ApplicationInWorkResponse>(response, true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
var query = robotConfigurationService.Get()
|
var query = robotConfigurationService.Get()
|
||||||
.Where(t => t.RobotCode == (int)robotCode && t.TaskStatusCode == (int)taskStatusCode);
|
.Where(t => t.RobotCode == (int)robotCode && t.TaskStatusCode == (int)taskStatusCode);
|
||||||
|
|
||||||
//var query = robotConfigurationService.Get();
|
//var query = robotConfigurationService.GetAsync();
|
||||||
|
|
||||||
switch (robotCode)
|
switch (robotCode)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace PARR.API.Validators
|
|||||||
if (isValid.HasValue)
|
if (isValid.HasValue)
|
||||||
return isValid.Value;
|
return isValid.Value;
|
||||||
|
|
||||||
isValid = await applicationsInWorkService.Get(applicationId, request.WorkId) != null;
|
isValid = await applicationsInWorkService.GetAsync(applicationId, request.WorkId) != null;
|
||||||
|
|
||||||
return isValid.Value;
|
return isValid.Value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace PARR.DAL.Services.Implementations
|
|||||||
|
|
||||||
protected override DataContext EntitiContext => dataContext;
|
protected override DataContext EntitiContext => dataContext;
|
||||||
|
|
||||||
public async Task<ApplicationsInWork?> Get(Guid applicationId, Guid workId)
|
public async Task<ApplicationsInWork?> GetAsync(Guid applicationId, Guid workId)
|
||||||
{
|
{
|
||||||
return await base.Get().FirstOrDefaultAsync(t => t.ApplicationId == applicationId && t.WorkId == workId);
|
return await base.Get().FirstOrDefaultAsync(t => t.ApplicationId == applicationId && t.WorkId == workId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,6 @@ namespace PARR.DAL.Services.Interfaces
|
|||||||
{
|
{
|
||||||
public interface IApplicationsInWorkService : IBaseService<ApplicationsInWork>
|
public interface IApplicationsInWorkService : IBaseService<ApplicationsInWork>
|
||||||
{
|
{
|
||||||
Task<ApplicationsInWork?> Get(Guid applicationId, Guid workId);
|
Task<ApplicationsInWork?> GetAsync(Guid applicationId, Guid workId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace PARR.GeneratorTemplates.Services
|
|||||||
if (service == null)
|
if (service == null)
|
||||||
throw new Exception($"Не найден сервис: {nameof(IApplicationsInWorkService)}");
|
throw new Exception($"Не найден сервис: {nameof(IApplicationsInWorkService)}");
|
||||||
|
|
||||||
return await service.Get(applicationId, workId) != null;
|
return await service.GetAsync(applicationId, workId) != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user