feat: corrigindo erro
This commit is contained in:
parent
d4ec1f72a6
commit
d37ea0c377
|
|
@ -49,7 +49,7 @@ namespace line_gestao_api.Controllers
|
|||
var normalizedConta = NormalizeContaValue(conta);
|
||||
if (string.IsNullOrWhiteSpace(normalizedConta)) return null;
|
||||
|
||||
return AccountCompanies
|
||||
return OperadoraContaResolver.GetAccountCompanies()
|
||||
.FirstOrDefault(group => group.Contas.Any(c => NormalizeContaValue(c) == normalizedConta))
|
||||
?.Empresa;
|
||||
}
|
||||
|
|
@ -530,9 +530,9 @@ namespace line_gestao_api.Controllers
|
|||
Cliente = clienteExibicao,
|
||||
line.Usuario,
|
||||
line.CentroDeCustos,
|
||||
SetorNome = line.Setor != null ? line.Setor.Nome : null,
|
||||
AparelhoNome = line.Aparelho != null ? line.Aparelho.Nome : null,
|
||||
AparelhoCor = line.Aparelho != null ? line.Aparelho.Cor : null,
|
||||
SetorNome = line.Setor != null ? line.Setor!.Nome : null,
|
||||
AparelhoNome = line.Aparelho != null ? line.Aparelho!.Nome : null,
|
||||
AparelhoCor = line.Aparelho != null ? line.Aparelho!.Cor : null,
|
||||
line.PlanoContrato,
|
||||
line.Status,
|
||||
line.Skil,
|
||||
|
|
@ -1337,21 +1337,24 @@ namespace line_gestao_api.Controllers
|
|||
// ==========================================================
|
||||
[HttpPost("batch-status-update")]
|
||||
[Authorize(Roles = "sysadmin,gestor")]
|
||||
public async Task<ActionResult<BatchLineStatusUpdateResultDto>> BatchStatusUpdate([FromBody] BatchLineStatusUpdateRequestDto req)
|
||||
public async Task<ActionResult<BatchLineStatusUpdateResultDto>> BatchStatusUpdate([FromBody] BatchLineStatusUpdateRequestDto? req)
|
||||
{
|
||||
var action = (req?.Action ?? "").Trim().ToLowerInvariant();
|
||||
if (req is null)
|
||||
return BadRequest(new { message = "Payload inválido para processamento em lote." });
|
||||
|
||||
var action = (req.Action ?? "").Trim().ToLowerInvariant();
|
||||
var isBlockAction = action is "block" or "bloquear";
|
||||
var isUnblockAction = action is "unblock" or "desbloquear";
|
||||
|
||||
if (!isBlockAction && !isUnblockAction)
|
||||
return BadRequest(new { message = "Ação inválida. Use 'block' ou 'unblock'." });
|
||||
|
||||
var blockStatus = NormalizeOptionalText(req?.BlockStatus);
|
||||
var blockStatus = NormalizeOptionalText(req.BlockStatus);
|
||||
if (isBlockAction && string.IsNullOrWhiteSpace(blockStatus))
|
||||
return BadRequest(new { message = "Informe o tipo de bloqueio para bloqueio em lote." });
|
||||
|
||||
var applyToAllFiltered = req?.ApplyToAllFiltered ?? false;
|
||||
var ids = (req?.LineIds ?? new List<Guid>())
|
||||
var applyToAllFiltered = req.ApplyToAllFiltered;
|
||||
var ids = (req.LineIds ?? new List<Guid>())
|
||||
.Where(x => x != Guid.Empty)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
|
@ -1378,7 +1381,7 @@ namespace line_gestao_api.Controllers
|
|||
baseQuery = _db.MobileLines.Where(x => ids.Contains(x.Id));
|
||||
}
|
||||
|
||||
var userFilter = (req?.Usuario ?? "").Trim();
|
||||
var userFilter = (req.Usuario ?? "").Trim();
|
||||
if (!applyToAllFiltered && !string.IsNullOrWhiteSpace(userFilter))
|
||||
{
|
||||
baseQuery = baseQuery.Where(x => EF.Functions.ILike(x.Usuario ?? "", $"%{userFilter}%"));
|
||||
|
|
@ -5353,7 +5356,7 @@ namespace line_gestao_api.Controllers
|
|||
|
||||
private static void ApplyBlockedLineToReservaContext(MobileLine line)
|
||||
{
|
||||
if (!ShouldAutoMoveBlockedLineToReserva(line?.Status)) return;
|
||||
if (!ShouldAutoMoveBlockedLineToReserva(line.Status)) return;
|
||||
line.Usuario = "RESERVA";
|
||||
line.Skil = "RESERVA";
|
||||
if (string.IsNullOrWhiteSpace(line.Cliente))
|
||||
|
|
|
|||
Loading…
Reference in New Issue